I need the best way of finding how many numbers in a string, would I have to first remove everything but numbers and then strlen?
Also how would I go about testing the performance of a any PHP script I have written, say for speed and performance under certain conditions?
UPDATE
say I had to inlcude ½ half numbers, its definetly preg then is it not?
You can just split the string with preg_split() and count the parts:
For performance you could use microtime().
eg:
For execution time:
For memory usage:
http://us.php.net/manual/en/function.memory-get-usage.php
For peak memory:
http://us.php.net/manual/en/function.memory-get-peak-usage.php
There are also specific PHP profiling tools like XDebug.
There is a good tutorial on using it with Eclipse:
http://devzone.zend.com/article/2930
There is also benchmark in PEAR:
http://pear.php.net/package/Benchmark/docs/latest/Benchmark/Benchmark_Profiler.html
And a list of others:
http://onwebdevelopment.blogspot.com/2008/06/php-code-performance-profiling-on.html