note 67982 added to function.explode

From: Date: Sat, 08 Jul 2006 15:22:07 +0000
Subject: note 67982 added to function.explode
Groups: php.notes 
Request: Send a blank email to php-notes+get-114594@lists.php.net to get a copy of this message
The markus function will echo "Found more than 2 encapsulations - this should not happen!", when invoked with a string containing escaped $encap characters. For example: $delim = ","; $string = "'first,data','second,data','it\\'s the last data'"; $encap = "'"; quote_explode( $delim, $string, $encap ); The following small modification to the markus function seems to prevent escaped $encap characters from being considered as the terminating $encap character. Replace the line: $numEncaps = substr_count( $part, $encap ); With the line: $numEncaps = substr_count( $part, $encap ) - substr_count( $part, '\\\\'.$encap ); ---- Server IP: 66.163.161.117 Probable Submitter: 83.67.57.153 ---- X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER autolearn=no version=2.64 ---- Manual Page -- http://www.php.net/manual/en/function.explode.php Edit -- http://master.php.net/note/edit/67982 Del: integrated -- http://master.php.net/note/delete/67982/integrated Del: useless -- http://master.php.net/note/delete/67982/useless Del: bad code -- http://master.php.net/note/delete/67982/bad+code Del: spam -- http://master.php.net/note/delete/67982/spam Del: non-english -- http://master.php.net/note/delete/67982/non-english Del: in docs -- http://master.php.net/note/delete/67982/in+docs Del: other reasons-- http://master.php.net/note/delete/67982 Reject -- http://master.php.net/note/reject/67982 Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#114594) next »