Re: using for loop in function

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux