This script is unusable for anything other than WAVs of a few seconds or so. For anything longer than a few seconds, it takes a huge amount of time and memory to execute. For one thing, it creates an array element for EVERY block in the WAV?!?! When you consider how much memory arrays used in PHP, this is utterly ridiculous.
If you are only producing a small waveform image, there is no point to sample more than once per every 128 or 256 frames to get the same basic result over the resolution that any user is likely to need from a PHP generated image. Plus, once the average level value for a particular pixel has been calculated, there is not reason to keep the data for that pixel in memory.
This script is very slow, and very memory consuming and basically, useless for anything other than a very very small WAV file.