note 119220 added to function.split

From: Date: Thu, 21 Apr 2016 03:46:27 +0000
Subject: note 119220 added to function.split
Groups: php.notes 
Request: Send a blank email to php-notes+get-205293@lists.php.net to get a copy of this message
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); ?> ---- Server IP: 72.52.91.14 Probable Submitter: 103.224.164.159 ---- Manual Page -- http://php.net/manual/en/function.split.php Edit -- https://master.php.net/note/edit/119220 Del: integrated -- https://master.php.net/note/delete/119220/integrated Del: useless -- https://master.php.net/note/delete/119220/useless Del: bad code -- https://master.php.net/note/delete/119220/bad+code Del: spam -- https://master.php.net/note/delete/119220/spam Del: non-english -- https://master.php.net/note/delete/119220/non-english Del: in docs -- https://master.php.net/note/delete/119220/in+docs Del: other reasons-- https://master.php.net/note/delete/119220 Reject -- https://master.php.net/note/reject/119220 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#205293) next »