note 119220 deleted from function.split by mazzanet

From: Date: Thu, 21 Apr 2016 09:23:24 +0000
Subject: note 119220 deleted from function.split by mazzanet
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-205296@lists.php.net to get a copy of this message
Note Submitter: alex at alex dot com ---- The second example is wrong. You have to escape special regex characters such as slashes, dots or hypens. <?php // Delimiters may be slash, dot, or hyphen $date = "04/30/1973"; list($month, $day, $year) = split('[/.-]', $date); echo "Month: $month; Day: $day; Year: $year<br />\n"; ?> <?php // this line : list($month, $day, $year) = split('[/.-]', $date); //should be: list($month, $day, $year) = split('[\/\.\-]', $date); ?>

« previous php.notes (#205296) next »