Page 1 sur 1

création d'un tableau à partir d'un autre tableau

Posté : 09 mars 2011, 19:42
par light86
bonsoir à tous le monde j'ai un tableau $_POST
voici ses élements

Code : Tout sélectionner

'alain' => string 'alain' (length=5) 'header' => string ' ' (length=1) 'alain11' => string 'alain' (length=5) 'alain12' => string 'val1' (length=4) 'alain13' => string 'g' (length=1)
je voudrais créez un tableau de tout les élement qui commence alain sauf le premier

j'ai pensé à utilisez les expression régulières mais comment créez un autre tableau à partir de $_post
je vous remercie

Re: création d'un tableau à partir d'un autre tableau

Posté : 10 mars 2011, 10:18
par Mazarini
Bonjour,
foreach ($tableau as $k=>$v)
{
   if (substr($k,0,5) == 'alain' and len($k) > 5)
   {
      $nouveau[$k] = $v;
   }
}