Re: using for loop in function

From: Date: Wed, 28 Mar 2007 12:03:18 +0000
Subject: Re: using for loop in function
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-251531@lists.php.net to get a copy of this message
Richard Kurth wrote:
The function below will create a group of checkboxes it will also check the checkbox that is stored in the table field that is in $select_value this works fine if there is only one value in the variable but if there is more stored like 1,2,3,4 it will not work. I am trying to figure out how to use the following for loop to add the number to each checkbox and if they match mark the checkbox checked $ExplodeIt = explode(",",$select_value,",");
        $Count = count($ExplodeIt);
        for ($i=0; $i < $Count; $i++) {
          }
$select_value = "1,2,3,4"; $ExplodeIt = explode(",",$select_value,","); Using print_r(), you will get Array (
       [0] => 1,2,3,4
) count($ExplodeIt) = 1 $ExplodeIt = explode(",",$select_value); Using print_r(), you will get: Array (
       [0] => 1
       [1] => 2
       [2] => 3
       [3] => 4
) count($ExplodeIt) = 4 -- _____________________ Myron Turner http://www.room535.org http://www.bstatzero.org http://www.mturner.org/XML_PullParser/

« previous php.general (#251531) next »