note 90217 added to function.explode

From: Date: Fri, 10 Apr 2009 19:01:58 +0000
Subject: note 90217 added to function.explode
Groups: php.notes 
Request: Send a blank email to php-notes+get-153056@lists.php.net to get a copy of this message
If you explode an empty string, it does not return an empty array. It returns a single element array with an empty element. $test = ''; $test_array = explode(',',$test); print_r($test_array); // returns Array ( [0] => ) I was expecting it to act more like this: $test = ''; $test_array = $test ? explode(',',$test) : array(); print_r($test_array); // returns Array () ---- Server IP: 209.41.74.194 Probable Submitter: 69.60.8.129 ---- Manual Page -- http://www.php.net/manual/en/function.explode.php Edit -- https://master.php.net/note/edit/90217 Del: integrated -- https://master.php.net/note/delete/90217/integrated Del: useless -- https://master.php.net/note/delete/90217/useless Del: bad code -- https://master.php.net/note/delete/90217/bad+code Del: spam -- https://master.php.net/note/delete/90217/spam Del: non-english -- https://master.php.net/note/delete/90217/non-english Del: in docs -- https://master.php.net/note/delete/90217/in+docs Del: other reasons-- https://master.php.net/note/delete/90217 Reject -- https://master.php.net/note/reject/90217 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#153056) next »