php - putting the array data into separate variables -
i trying put array data 2 separate variables. not getting it. here code
if($option_query->row['type'] == 'date') { $array1[0] = $option_value; foreach ($array1 $key => $value) { echo "$key = $value<br>"; }
now getting result :
0 = 2013-05-05 0 = 2013-05-07
i want put 1st date in variable called datestart
, 2nd date in dateend
. how can achieve this?
output var_dump(array1);
array (size=1) 0 => string '2013-05-05' (length=10) array (size=2) 0 => string '2013-05-05' (length=10) 1 => string '2013-05-07' (length=10)
edited here (adding)
if($option_query->row['type'] == 'date' ) { $arr = array( //assuming should map of array array( $option_value ), array( $option_value //$option_value ) ); // var_dump($arr); echo $arr[1][0]; echo $arr[1][1]; } }
i echoed , got o/p
2013-05-20 2013-05-30
it works!!!!!
there's no need loop, if you've array like
$arr = array('1/2/2010', '2/2/2012'); $start_date = $arr[0]; //assigning 1st index var $end_date = $arr[1]; //assigning 2nd index var
update : array nested array, need use this
<?php $arr = array( //assuming should map of array array( '2013-05-05' ), array( '2013-05-05', '2013-05-07' ) ); var_dump($arr); echo $arr[1][0]; echo $arr[1][1]; ?>
Comments
Post a Comment