how to display the value separate into string, integer and double in php -
how can display value separate string, integer , double in php using multidimensional array?
here's code:
<?php $array = array( array ("one"=>1,"two"=>"two","three"=>3.1,"four"=>4,"five"=>"five"), array ("six"=>6.1,"seven"=>7,"eight"=>"eight","nine"=>9.1,"ten"=>10), array ("eleven"=>"eleven","twelve"=>12.1,"thirteen"=>13,"fourteen"=>"fourteen","fifteen"=>15.1), array ("sixteen"=>16,"seventeen"=>"seventeen","eighteen"=>18.1,"nineteen"=> 19,"twenty"=>"twenty"), array ("twenty-one"=>21.1,"twenty-two"=>22,"twenty-three"=>"twenty-three","twenty-four"=>24.1,"twenty-five"=>25) );
use 2 foreach statement, 1 each array , 1 loop value , use switch/case determine value , according add value array of type
$integer=array(); $double=array(); $string=array() foreach ($rows $row) { foreach($row $key=>$value){ switch (true){ case is_string($value): // string $string[]=$value; break; case is_int($value): // int $integer[]=$value; break; case is_float($value); // double $double[]=$value; break; default: } } }
Comments
Post a Comment