note 121140 deleted from function.explode by salathe

From: Date: Mon, 21 Sep 2020 14:48:36 +0000
Subject: note 121140 deleted from function.explode by salathe
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-215320@lists.php.net to get a copy of this message
Note Submitter: auramgold ---- Simple function to explode a string with keys specified in the string. <?php function explode_with_keys($delim1,$delim2,$inputstring) { $firstarr = explode($delim1,$inputstring); $finalarr = array(); foreach($firstarr as $set) { $setarr = explode($delim2,$set); $finalarr[$setarr[0]] = $setarr[1]; } return $finalarr; } print_r(explode_with_keys(";",":","a:b;c:d;e:f")); ?> Will output: Array ( [a] => b [c] => d [e] => f )

« previous php.notes (#215320) next »