View on GitHub


Sounds of NY

Sounds of NY is a project that lets you submit sounds of the city. It uses an email php parser and a processing sketch. The parser was written by Shawn Van Every. By emailing z e v e n w o l f . p i c s  at  g m a i l . c o m and attach your mp3 the sketch picks up the last sound uploaded.

The one thing I had to used fix the parser was when I would post to the database it included my server’s httpdocs in the url path. I used regular expressions to take the /httpdocs/ out. In php, the / starts and ends the regular expression. [^A-Za-z0-9] this sections chooses any non-number and letter in this case the first /. Then it finds httpdocs. Then [^A-Za-z0-9] finds the second /.

[cc lang=”php”]

$tempData = $data[0][‘sound’];
$patterns = “/[^A-Za-z0-9]httpdocs[^A-Za-z0-9]/”;
$replacements = ‘/’;
echo preg_replace($patterns, $replacements, $tempData);