note 123575 added to function.explode

From: Date: Thu, 31 Jan 2019 19:25:03 +0000
Subject: note 123575 added to function.explode
Groups: php.notes 
Request: Send a blank email to php-notes+get-210153@lists.php.net to get a copy of this message
Issue with '#' inside string If you try something like this this you will face with issue: ---------------------------------------------------------------------------- $str = "bill_name2=mabennett&bill_street=1977+sw+peterson+st+#300&bill_city=1"; function parse_q_string(string $q_string = '') { if (trim($q_string) == '') { return []; } $result = []; $particlesPairsArr = explode('&', $q_string); foreach ($particlesPairsArr as $piece) { $pair = explode('=', $piece); if (!empty($pair[0])) { $result[$pair[0]] = isset($pair[1]) ? $pair[1] : ''; } } var_dump( $result ); } parse_q_string($str); ----------------------------------------------------------- Result is a broken array by '#' inside the string: array(4) { ["bill_name2"]=> string(11) "'mabennett'" ["bill_street"]=> string(22) "'1977+sw+peterson+st+'" } ---- Server IP: 208.43.231.9 Probable Submitter: 185.85.3.194 (proxied: 93.86.178.33) ---- Manual Page -- http://php.net/manual/en/function.explode.php Edit -- https://master.php.net/note/edit/123575 Del: integrated -- https://master.php.net/note/delete/123575/integrated Del: useless -- https://master.php.net/note/delete/123575/useless Del: bad code -- https://master.php.net/note/delete/123575/bad+code Del: spam -- https://master.php.net/note/delete/123575/spam Del: non-english -- https://master.php.net/note/delete/123575/non-english Del: in docs -- https://master.php.net/note/delete/123575/in+docs Del: other reasons-- https://master.php.net/note/delete/123575 Reject -- https://master.php.net/note/reject/123575 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#210153) next »