Hey Chubbs, would you fancy some pizza?
I've placed my favourite toppings in this array. You may use print_r to peruse the order before I call it in.
<?
$pizza = ['cheese','sauce','green peppers','onions','anchovies'];
?>
print_r($pizza);
Array
(
[0] => cheese
[1] => sauce
[2] => green peppers
[3] => onions
[4] => anchovies
)
My dear Hippolyte, you know very well that I do not care for anchovies.
I will pop them from the array, adding chunky bacon in their stead.
<?
array_pop($pizza);
$pizza[] = 'chunky bacon';
?>
print_r($pizza);
Array
(
[0] => cheese
[1] => sauce
[2] => green peppers
[3] => onions
[4] => chunky bacon
)
Gentlemen, I come bearing wine.
Allow me to add a second pizza. I'll place both pizzas in a new order array.
<?
$order = [$pizza,
['feta cheese',
'extra sauce',
'pepperoni',
'olives']];
?>
Holy white-space Batman! What a magnanimous way to format an array.
Magnanimous indeed, Robin. I'll call in the order posthaste.
Then we shall drink wine and be merry.
print_r($order);
Array
(
[0] => Array
(
[0] => cheese
[1] => sauce
[2] => green peppers
[3] => onions
[4] => chunky bacon
)
[1] => Array
(
[0] => feta cheese
[1] => extra sauce
[2] => pepperoni
[3] => olives
)
)