note 111650 deleted from function.explode by salathe

From: Date: Mon, 21 Sep 2020 14:50:31 +0000
Subject: note 111650 deleted from function.explode by salathe
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-215347@lists.php.net to get a copy of this message
Note Submitter: Hayley Watson ---- The comments to use array_filter() without a callback to remove empty strings from explode's results miss the fact that array_filter will remove all elements that, to quote the manual, "are equal to FALSE". This includes, in particular, the string "0", which is NOT an empty string. If you really want to filter out empty strings, use the defining feature of the empty string that it is the only string that has a length of 0. So: <?php array_filter(explode(':', "1:2::3:0:4"), 'strlen'); ?>

« previous php.notes (#215347) next »