note 93778 added to function.explode

From: Date: Mon, 28 Sep 2009 22:20:42 +0000
Subject: note 93778 added to function.explode
Groups: php.notes 
Request: Send a blank email to php-notes+get-161130@lists.php.net to get a copy of this message
Note to the previous example: we can do the whole string->array conversion using explode() exclusively. <?php // converts pure string into a trimmed keyed array function string_2_array( $string, $delimiter = ',', $kv = '=>') { if ($element = explode( $delimiter, $string )) { // create parts foreach ( $element as $key_value ) { // key -> value pair or single value $atom = explode( $kv, $key_value ); if( trim($atom[1]) ) { $key_arr[trim($atom[0])] = trim($atom[1]); } else { $key_arr[] = trim($atom[0]); } } } else { $key_arr = false; } return $key_arr; } ?> ---- Server IP: 209.41.74.194 Probable Submitter: 65.65.116.130 ---- Manual Page -- http://www.php.net/manual/en/function.explode.php Edit -- https://master.php.net/note/edit/93778 Del: integrated -- https://master.php.net/note/delete/93778/integrated Del: useless -- https://master.php.net/note/delete/93778/useless Del: bad code -- https://master.php.net/note/delete/93778/bad+code Del: spam -- https://master.php.net/note/delete/93778/spam Del: non-english -- https://master.php.net/note/delete/93778/non-english Del: in docs -- https://master.php.net/note/delete/93778/in+docs Del: other reasons-- https://master.php.net/note/delete/93778 Reject -- https://master.php.net/note/reject/93778 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#161130) next »