fork download
  1. <?php
  2.  
  3. $arr = array(
  4. 'id' => '147',
  5. 'nome' =>'João',
  6. 'email' => 'joao@teste.com',
  7. 'data_nascimento' => '05/01/1987',
  8. 'numero_1' => '1',
  9. 'rua_1' => 'rua 1',
  10. 'numero_2' => '2',
  11. 'rua_2' => 'rua 2',
  12. 'submit' => 'Salvar'
  13. );
  14.  
  15. $newArr = array();
  16.  
  17. foreach ($arr as $k => $v)
  18. if (strpos($k, "numero_") === 0)
  19. $newArr[$k] = $v;
  20.  
  21.  
  22. var_dump($newArr);
  23.  
Success #stdin #stdout 0.01s 20568KB
stdin
Standard input is empty
stdout
array(2) {
  ["numero_1"]=>
  string(1) "1"
  ["numero_2"]=>
  string(1) "2"
}