You are here: how to delete record in an array of arrays ? « PHP Language « IT news, forums, messages
how to delete record in an array of arrays ?

Posted by fabrice rιgnier on 02/15/07 13:42

Hi all ;)

Here is my array of arrays:

$res= array();
$res[]=array("name" => "Smith" , "age" => 10);
$res[]=array("name" => "Johnson" , "age" => 20);
$res[]=array("name" => "Adam" , "age" => 0);
$res[]=array("name" => "Sullivan" , "age" => 15);

print_r($res);

Array (
[0] => Array ( [name] => Smith [age] => 10 )
[1] => Array ( [name] => Johnson [age] => 20 )
[2] => Array ( [name] => Adam [age] => 0 )
[3] => Array ( [name] => Sullivan [age] => 15 )
)

My question is: i'd like to delete all records that have their age = 0

As a result, i'd like to see :

Array (
[0] => Array ( [name] => Smith [age] => 10 )
[1] => Array ( [name] => Johnson [age] => 20 )
[2] => Array ( [name] => Sullivan [age] => 15 )
)

I've tried array_filter, array_splice, unset & array_shift but without
any success. I guess i miss something in the multi-dimensional array
management.

Thanx in advance ;)

f.

 

Navigation:

[Reply to this message]


УдалСнная Ρ€Π°Π±ΠΎΡ‚Π° для программистов  •  Как Π·Π°Ρ€Π°Π±ΠΎΡ‚Π°Ρ‚ΡŒ Π½Π° Google AdSense  •  England, UK  •  ΡΡ‚Π°Ρ‚ΡŒΠΈ Π½Π° английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Π‘Π°ΠΉΡ‚ ΠΈΠ·Π³ΠΎΡ‚ΠΎΠ²Π»Π΅Π½ Π² Π‘Ρ‚ΡƒΠ΄ΠΈΠΈ Π’Π°Π»Π΅Π½Ρ‚ΠΈΠ½Π° ΠŸΠ΅Ρ‚Ρ€ΡƒΡ‡Π΅ΠΊΠ°
ΠΈΠ·Π³ΠΎΡ‚ΠΎΠ²Π»Π΅Π½ΠΈΠ΅ ΠΈ ΠΏΠΎΠ΄Π΄Π΅Ρ€ΠΆΠΊΠ° Π²Π΅Π±-сайтов, Ρ€Π°Π·Ρ€Π°Π±ΠΎΡ‚ΠΊΠ° ΠΏΡ€ΠΎΠ³Ρ€Π°ΠΌΠΌΠ½ΠΎΠ³ΠΎ обСспСчСния, поисковая оптимизация