Member since 08/08/2006

5 snippets

11 profile views

0 Comment(s) Posted

View their favorites


All time reputation: 35


first submission:submitting first snipplet popular snippet:having a snipplet with 20 favorites

mthorn's Recent Snippets

« Prev 1 Next »
  1. FAV

    Speed Test: array_push vs $array[]

    Took 0.164692 seconds for array[] Took 0.395778 seconds for array_push As you can see array_push is more than twice as slow. Here are the reasons. Array_push is a function call, Function calls are always slower. Array_push takes mixed parameters,...
    PHP 20 views posted 13 years ago mthorn
  2. FAV

    Speed Test: strcmp vs ===

    strcmp with matching strings took 0.207852 seconds strcmp with non-matching strings took 0.215276 seconds === with matching strings took 0.067122 seconds === with non-matching strings took 0.057305 seconds === is the clear winner. Function call...
    PHP 14 views posted 13 years ago mthorn
  3. FAV

    Compare value _and_ type

    Since PHP is typeless odd things can happen when a variable is not the type you expected. PHP treats 0, null, '0', false, and '' as false. Sometimes you really want to know if the value is false. The solution is simple, use the triple equal (===) ope...
    PHP 5 views posted 13 years ago mthorn
  4. FAV

    Read raw post data, useful for grabbing XML from Flash XmlSocket.

    Often PHP can't interpret POST data because it is not form-encoded. This is typical when the post data is XML from API's like Flash's XmlSocket. You can use the following methods to read the POST data directly.
    PHP saved by 36 people 13 views posted 13 years ago mthorn
  5. FAV

    Create a thumbnail maintaining aspect ratio using GD

    Will create a thumnail no taller or wider than the supplied size. Also contains some tips for reading and writing images using GD.
    PHP saved by 22 people 35 views posted 13 years ago mthorn
« Prev 1 Next »