NYCPHP Meetup

convert str array to int ???

Tracy tech_learner at yahoo.com
Thu Mar 20 01:07:04 EST 2003


Hi,
i have a script which works with integers. i am taking the inputs from a form and now it defaults to string. a var_dump gives :

INPUTS : 
array(2) {
  [0]=>
  array(2) {
    [0]=>
    string(1) "0"
    [1]=>
    string(1) "1"
  }
  [1]=>
  array(2) {
    [0]=>
    string(1) "1"
    [1]=>
    string(1) "1"
  }
}

but i need the values to be ints....

i tried :

foreach ($pieces as $k => $v) {
 $$k = $v;
 echo $k ."=". $v ."<br>";
//var_dump ($v);
 $cast = is_array ($v);
 if ($cast) {
  foreach ($v as $key => $val) {
   $$key = $val;
   echo $key ."=". $val ."<br>";

   $chk = is_int($val);
   echo "variable type : $chk <br>";
   if (!$chk) settype ($val,"integer");
  }
 }
}

but still i am not able to type juggle. i have missed something but i am unable to find out what. can someone plz identify what it is?
is there a better way, i am not sure i am coding in the right way...

also, i have two arrays, i want to merge them as :
new[0] = array1[0], array2[0], array2[1]
new[1] = array1[1], array2[1], array2[1]

how to do this, i am again not getting the results like expected.

Thz
Tracy


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Coming together is a beginning... 
   keeping together is progress... 
      working together is success !!!
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


---------------------------------
Do you Yahoo!?
Yahoo! Platinum - Watch CBS' NCAA March Madness, live on your desktop!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.nyphp.org/pipermail/talk/attachments/20030319/0e206fca/attachment.html>


More information about the talk mailing list