note 105179 deleted from function.range by danbrown

From: Date: Mon, 01 Aug 2011 16:34:26 +0000
Subject: note 105179 deleted from function.range by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-182079@lists.php.net to get a copy of this message
Note Submitter: Ray dot Paseur at Gmail dot com ---- Be VERY careful if you use range() to generate an array of numeric strings. Even though the input is quoted, the resulting array contains integers, not strings. <?php // RAY_temp_range.php error_reporting(E_ALL); // A RANGE OF NUMBERS $numbrs = range("0", "9"); // AN ARRAY OF NUMERIC CHARACTERS $alphas = array(); foreach ($numbrs as $n) { $alphas[] = "$n"; } // THEY LOOK THE SAME print_r($numbrs); echo "<br/>"; print_r($alphas); // BUT THEY ARE DIFFERENT echo "<pre>"; var_dump($numbrs); var_dump($alphas);

« previous php.notes (#182079) next »