Re: Crear elemento al principio de una matriz
| From: | orion at sarenet dot es | Date: | Thu, 13 Feb 2003 19:03:12 +0000 |
| Subject: | Re: Crear elemento al principio de una matriz | ||
| References: | 1 | Groups: | php.general.es |
| Request: | Send a blank email to general-es+get-32362@lists.php.net to get a copy of this message | ||
Buenas,
¿haciendo un for inverso?
<?
for ($i=count($matriz); $i>0; $i--){
$matriz[$i]=$matriz[$i-1];
}
$matriz[0]["Nombre"] = "Felipe";
$matriz[0]["DNI"] = "9999999T";
?>
Saludos,
Jose
> Tengo una matriz parecida a la siguiente:
>
> $matriz[0]["Nombre"] = "Paco";
> $matriz[0]["DNI"] = "77777777T";
> $matriz[1]["Nombre"] = "Pedro";
> $matriz[1]["DNI"] = "88888888T";
>
> como podría crear otro elemento de la matriz al principio para insertar ...
> $matriz[0]["Nombre"] = "Felipe";
> $matriz[0]["DNI"] = "9999999T";
>
>
>
> ---------------------------------------------------------------------
> Archivo On-line: http://www.phpes.com/
> via news: news://news.phpes.com/
> Manual PHP en español: http://www.php.net/manual/es/
> Para dar de baja la suscripción, mande un mensaje a:
> lista-unsubscribe@phpes.com