Change the existing array key value in PHP -


my requirement show list of dates in array , time available in particular date.

i got set logic struggling in 1 place, please down issue.

i have array below, need change 'booked_from_time' 'from_time' dynamically ever want.

how can achieve this, please me achieve solution it.

<!-- array response -->  [2016-11-25] => array     (         [0] => array             (                 [from_time] => 00:00:00                 [to_time] => 23:59:59             )      )  [2016-11-26] => array     (         [0] => array             (                 [booked_from_time] => 2016-11-26 00:00:00                 [booked_to_time] => 2016-11-26 16:00:00             )          [1] => array             (                 [booked_from_time] => 2016-11-26 16:00:00                 [booked_to_time] => 2016-11-26 19:20:00             )          [2] => array             (                 [from_time] => 00:00:00                 [to_time] => 23:59:59             )      )  [2016-11-27] => array     (         [0] => array             (                 [from_time] => 00:00:00                 [to_time] => 23:59:59             )      ) //my php code function multiplebookingsinaday($templist){     foreach($templist $key => $datavalue){         $previousfromdate;         foreach($datavalue $keyone => $innerdata){              if(isset($innerdata['booked_from_time'])){                 $tempstarttime = date('y-m-d h:i:s',strtotime($key . " 00:00:00"));                 $tempfromtime = date('y-m-d h:i:s',strtotime($key . " " . $innerdata['booked_from_time']));                 if(empty($previousfromdate)){                     $previousfromdate = date('y-m-d h:i:s',strtotime($key . " 00:00:00"));                 }                 $templist[$key][$keyone]['booked_from_time'] = $previousfromdate;                 $templist[$key][$keyone]['booked_to_time'] = $tempfromtime;                 $previousfromdate = $tempfromtime;                 continue;             }             break;         }     }     print_r($templist); } 

thanks in advance.

i have fixed issue of below link.

replace array keys

thank you.


Comments

Popular posts from this blog

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -