note 86655 added to function.explode
| From: | shag134 at hotmail dot com | Date: | Tue, 28 Oct 2008 17:53:39 +0000 |
| Subject: | note 86655 added to function.explode | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-145893@lists.php.net to get a copy of this message | ||
Hola hice un par de funciones para el que quiera convertir un array a texto y viceversa conservando
los indices... espero a alguien le sirvan saludos!
function key_explode($array){
$text_array = NULL;
foreach($array as $key => $val){
$text_array .= $key .'=>'. $val .':::';
}
$text_array = substr($text_array, 0, -3);
return $text_array;
}
function key_implode($text_array){
$array = NULL;
$sub_arrays = explode(":::", $text_array);
foreach($sub_arrays as $val){
$sub_array = explode("=>" , $val);
$array[$sub_array[0]] = $sub_array[1];
}
return $array;
}
en mi caso el separador es ::: pero se puede usar una variable para que el usuario defina el que el
guste ;)
----
Server IP: 69.147.83.197
Probable Submitter: 189.155.11.74
----
Manual Page -- http://www.php.net/manual/en/function.explode.php
Edit -- https://master.php.net/note/edit/86655
Del: integrated -- https://master.php.net/note/delete/86655/integrated
Del: useless -- https://master.php.net/note/delete/86655/useless
Del: bad code -- https://master.php.net/note/delete/86655/bad+code
Del: spam -- https://master.php.net/note/delete/86655/spam
Del: non-english -- https://master.php.net/note/delete/86655/non-english
Del: in docs -- https://master.php.net/note/delete/86655/in+docs
Del: other reasons-- https://master.php.net/note/delete/86655
Reject -- https://master.php.net/note/reject/86655
Search -- https://master.php.net/manage/user-notes.php