note 47628 added to function.explode

From: Date: Tue, 23 Nov 2004 10:59:49 +0000
Subject: note 47628 added to function.explode
Groups: php.notes 
Request: Send a blank email to php-notes+get-80915@lists.php.net to get a copy of this message
The separator parameter in double quotes not single ones. Having got into the habit (for performance) of using double quotes only when I really want variable substitution etc, I was doing this (intending to split a string into lines) <?PHP $strFoo = "Hello World Goodbye World"; $arrFoo = explode ('\n', $strFoo); ?> and it wasn't working. I changed the single quotes for double ones and it started working. (Incidentally I then recombined the array back into a string implode()d with '\' (the Javascript line continuation character) to give a multi-line string that could be document.write()'d with Javascript). ---- Manual Page -- http://www.php.net/manual/en/function.explode.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+47628 Delete -- http://master.php.net/manage/user-notes.php?action=delete+47628&report=yes Reason: bad code -- http://master.php.net/manage/user-notes.php?action=delete+47628&report=yes&reason=bad+code Reason: spam -- http://master.php.net/manage/user-notes.php?action=delete+47628&report=yes&reason=spam Reason: useless example -- http://master.php.net/manage/user-notes.php?action=delete+47628&report=yes&reason=useless+example Reason: contains commercial links -- http://master.php.net/manage/user-notes.php?action=delete+47628&report=yes&reason=contains+commercial+links Reason: useless note -- http://master.php.net/manage/user-notes.php?action=delete+47628&report=yes&reason=useless+note Reject -- http://master.php.net/manage/user-notes.php?action=reject+47628&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#80915) next »