If I define an array in PHP such as (I don't define its size):
$cart = array();
Do I simply add elements to it using?:
$cartData[] = 13;
$cartData[] = "foo";
$cartData[] = obj;
Don't arrays in PHP have a add method, i.e. cart.add(13)?
|
Both array_push and the method you described will work.
Is the same as:
|
|||||
|
Its better to not use array_push and just use what you suggested. The functions just add overhead.
|
|||||||||
|
It's called array_push: http://il.php.net/function.array-push |
|||
|
You can use array_push. It adds the elements to the end of the array, like in a stack. You could have also done it like this:
|
||||
|