1. If a method can be static, declare it static. Speed improvement.
2. str_replace is faster than preg_replace, but strtr is faster than str_replace .
3. $row['id'] is 7 times faster than $row[id] , because if you don't supply quotes it has to guess which index you meant, assuming you didn't mean a constant.
4. Do not use functions inside of for loop, such as for ($x=0; $x < count($array); $x) The count() function gets called each time.
5. echo is faster than print