Re: Array to String
| From: | inyaki at websonline dot net | Date: | Tue, 15 Feb 2005 16:14:28 +0000 |
| Subject: | Re: Array to String | ||
| References: | 1 2 3 4 | Groups: | php.general.es |
| Request: | Send a blank email to general-es+get-53385@lists.php.net to get a copy of this message | ||
function arraytostr ($array=array()) {
$length = 0;
$foreach ($array as $key => $value) {
$keystring .= "$key ";
$valuestring .= "$value ";
$length++;
}
return array($length,$keystring,$valuestring);
}
//sting to array
function strtoarray ($length="",$keystring="",$valuestring="") {
$keys = explode(" ",$keystring);
$values = explode(" ",$valuestring);
for ($i=0; $i < $length; $i++) {
$key = $keys[$i];
$newarray[$key] = $values[$i];
}
return $newarray;
}
> Hola.
>
> Lamentablemente explode e implode respectivamente no mantienen los
> indices, por lo tanto no valen para mi causa y dudo que sirvan para
> arrays bidimensionales :-(
>
> Gracias de todas formas :-)
>
> inyaki@websonline.net wrote:
>
> inyaki@websonline.net wrote:
>
>>Explode e implode respectivamente
>>
>>http://es.php.net/manual/es/function.implode.php
>>http://es.php.net/manual/es/function.explode.php
>>
>>
>>
>>>Hola.
>>>
>>>Hace tiempo use una funcion que servia para pasar un Array a un string,
>>>que te ponia muchos % en el texto que te daba.
>>>
>>>He estado buscando en php.net por la zona de arrays y no encuentro nada,
>>>tampoco funciona urlencode. Como podria pasar este array a texto de una
>>>forma sencilla y luego poder decodificarlo de nuevo.
>>>
>>>Gracias
>>>
>>>--
>>>PHP Spanish Localization Talk Mailing List (http://www.php.net/)
>>>To unsubscribe, visit: http://www.php.net/unsub.php
>>>
>>>
>>>
>>
>>
>>
>