How to add 1 element to the array?

$booked_defaults[$day][$startTime.'-'.$endTime] = $count + $currentCount;

here comes the array
[Fri] => Array
(
 [0200-0400] => 1
 [0000-0100] => 14
 [0000-0200] => 2
 [0100-0400] => 1
 [0100-0500] => 3
 [0100-0200] => 2 
 )

You need to add 1 more element, call it $test, how to do it?
July 4th 19 at 23:21
2 answers
July 4th 19 at 23:23
You can consider the length of the array and to write the new key.
Here you have the array:
$index = count($fri);//Read the number of elements
$fri[$index+1] = $somevariable //is written to the cell array, $index+1 value of variable some variable

Or you can use the array_push()
What is considered the length of the array and make a new key? If it is possible for a visual example, thank you - Thurman54 commented on July 4th 19 at 23:26
July 4th 19 at 23:25
Add to the end of the array?
$array[] = $test;
What would the output was something like
$booked_defaults[$day][$startTime.'-'.$endTime] = $count + $currentCount,$coast;

[Fri] => Array
(
[0200-0400] => 1 [0200-0400] => 500

)

Ie the first value is the number 2 is the cost - Thurman54 commented on July 4th 19 at 23:28
: the same key cannot - Thurman54 commented on July 4th 19 at 23:31

Find more questions by tags PHP