I am new to PHP and wants to know whether array's in PHP are LIFO or FIFO. For e.g.
$var1 = array('1','2','3');
They are what you make them :)
array_pop()
removes an item off the end of an array (the last item that was added)
array_shift()
removes the first item off the array (first one added).
So as you can see they are capable of behaving in both ways.
It all depends on how you implement your code.
Updated:
Well arrays are neither LIFO
or FIFO
. Actually, they are both IMO
. ie. They can behave in both ways. You can make use of the available functions in php the either way (as required), as mentioned by Lix above.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With