Re: Get the beginning array number

From: Date: Mon, 17 Sep 2001 23:56:01 +0000
Subject: Re: Get the beginning array number
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-67656@lists.php.net to get a copy of this message
try this, untested, on the fly type solution. :) foreach ($array as $key => $value) { if (strlen($value) > 0) { $FirstWithValue = $key; break; } } Now, $FirstWithValue should hold the key of the first element, so you could then use $array[$FirstWithValue] if you are using php older than version 4, exchange the foreach loop with a while loop. ----- Original Message ----- From: "Brandon Orther" <orther@webintellects.com> To: "PHP User Group" <php-general@lists.php.net> Sent: Monday, September 17, 2001 4:46 PM Subject: [PHP] Get the beginning array number > Hello, > > I have an array sent to my script that starts at different numbers each > time. Here is an example > > > $array[5] through $array[23] will have values but [0]-[4] will not. > > Is there a way for me to find the first element of an array with a value? > > Thank you, > > -------------------------------------------- > Brandon Orther > WebIntellects Design/Development Manager > brandon@webintellects.com > 800-994-6364 > www.webintellects.com > -------------------------------------------- > > > ---------------------------------------------------------------------------- ---- > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net

« previous php.general (#67656) next »