Hello, do not kick much, start PHP knowledge :) I can't get the value out of the array (you need to output the date [formatted] and the time [time] and [timeto].

print_r( $jckwds->get_reserved_slot() ); 

displays the following:

 Array ( [id] => 20170624_0 [date] => Array ( [formatted] => 24/06/2017 [id] => 20170624 ) [time] => Array ( [timefrom] => Array ( [time] => 02:30 [stripped] => 0230 ) [timeto] => Array ( [time] => 10:45 [stripped] => 1045 ) [cutoff] => [lockout] => 4 [shipping_methods] => Array ( [0] => any ) [fee] => Array ( [value] => [formatted] => €0,00 ) [days] => Array ( [0] => 0 [1] => 1 [2] => 6 ) [id] => 0 [time_id] => 02301045 [formatted] => 02:30 AM - 10:45 AM [formatted_with_fee] => 02:30 AM - 10:45 AM [value] => 0|0.00 ) ) 

The code with which I am trying to display at least the date:

  global $jckwds; $jckw = $jckwds->get_reserved_slot(); foreach($jckw as $key) { echo $key('date'); } 

2 answers 2

In order to easily understand the structure of a multidimensional array, first look at the structure.

 Array ( [id] => 20170624_0 [date] => Array ( [formatted] => 24/06/2017 [id] => 20170624 ) [time] => Array ( [timefrom] => Array ( [time] => 02:30 [stripped] => 0230 ) [timeto] => Array ( [time] => 10:45 [stripped] => 1045 ) [cutoff] => [lockout] => 4 [shipping_methods] => Array ( [0] => any ) [fee] => Array ( [value] => [formatted] => €0,00 ) [days] => Array ( [0] => 0 [1] => 1 [2] => 6 ) [id] => 0 [time_id] => 02301045 [formatted] => 02:30 AM - 10:45 AM [formatted_with_fee] => 02:30 AM - 10:45 AM [value] => 0|0.00 ) ) 

Further through foreach you can get a pair of key => value

 foreach($jckw as $key=>$val) { echo $val; /* или */ echo $jckw[$key]; } 

The $val variable already contains values, you can get them without a key if you need to get one value by key, for example

echo $jckw['date']['formatted']; or echo $jckw['time']['timefrom']['time'];

    The array element is accessed through square brackets. Round is a function call.

    In addition, date is an array and echo in this case will output an Array instead of a date.