RE: [PHP-ES] Iterate sobre Objectos para saber la cantidad

From: Date: Thu, 21 Aug 2008 15:37:02 +0000
Subject: RE: [PHP-ES] Iterate sobre Objectos para saber la cantidad
References: 1  Groups: php.general.es 
Request: Send a blank email to general-es+get-63052@lists.php.net to get a copy of this message
Seguramente esto te va a funcionar Suerte!! function array_search_recursive($needle, $haystack, $a=0, $nodes_temp=array()){ global $nodes_found; foreach ($haystack as $key1=>$value1) { $nodes_temp[$a] = $key1; if (is_array($value1)){ $a++; array_search_recursive($needle, $value1, $a, $nodes_temp); } else if ($value1 === $needle){ $nodes_found[] = $nodes_temp; } } $a--; return $nodes_found; } -----Mensaje original----- De: Carlos Medina [mailto:info@simply-networks.de] Enviado el: Jueves, 21 de Agosto de 2008 09:36 a.m. Para: php-es@lists.php.net Asunto: [PHP-ES] Iterate sobre Objectos para saber la cantidad Buenas Tardes, necesito saber la cantidad de attributes en una cantidad dada de objetos: Array ( [0] => Object ( [attr] => test [attr2]=> test2 ) [1] => Object ( [attr] => test_a [attr2]=> test2 ) [2] => Object ( [attr] => test [attr2]=> test2 ) ) Por ejemplo aqui necesitaria saber cuantos "attr" (no "attr2"), con value test existen en los tres objetos y cuantos existen con value test_a Se les ocurre algo? Saludos Carlos -- PHP Spanish Localization Talk Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

« previous php.general.es (#63052) next »