The append() function of the ArrayObject class in PHP is used to append a given value onto an ArrayObject. The value being appended can be a single value or an array itself.
Syntax:
void append($value)
Parameters: This function accepts a single parameter $value, representing the value to be appended.
Return Value: This function does not returns any value.
Below programs illustrate the above function:
Program 1:
<?php // PHP function to illustrate the // append() method $arrObj = new ArrayObject(array('Geeks', 'for', 'Geeks')); $arrObj->append('welcomes you'); var_dump($arrObj); ?> |
object(ArrayObject)#1 (1) {
["storage":"ArrayObject":private]=>
array(4) {
[0]=>
string(5) "Geeks"
[1]=>
string(3) "for"
[2]=>
string(5) "Geeks"
[3]=>
string(12) "welcomes you"
}
}
Program 2:
<?php // PHP function to illustrate the // append() method $arrObj = new ArrayObject(array('Geeks', 'for', 'Geeks')); // Appending an array $arrObj->append(array('welcomes', 'you')); var_dump($arrObj); ?> |
object(ArrayObject)#1 (1) {
["storage":"ArrayObject":private]=>
array(4) {
[0]=>
string(5) "Geeks"
[1]=>
string(3) "for"
[2]=>
string(5) "Geeks"
[3]=>
array(2) {
[0]=>
string(8) "welcomes"
[1]=>
string(3) "you"
}
}
}
Reference: http://php.net/manual/en/arrayobject.append.php
Recommended Posts:
- ArrayObject getIterator() Function in PHP
- ArrayObject asort() Function in PHP
- ArrayObject exchangeArray() function in PHP
- ArrayObject getArrayCopy() Function in PHP
- PHP | ArrayObject count() Function
- PHP | ArrayObject getFlags() Function
- PHP | ArrayObject unserialize() Function
- ArrayObject uksort() Function in PHP
- PHP | ArrayObject serialize() Function
- ArrayObject offsetExists() Function in PHP
- ArrayObject offsetUnset() Function in PHP
- ArrayObject getIteratorClass() Function in PHP
- PHP | ArrayObject setIteratorClass() Function
- ArrayObject offsetGet() Function in PHP
- ArrayObject offsetSet() Function in PHP
- ArrayObject uasort() Function in PHP
- ArrayObject natsort() Function in PHP
- ArrayObject natcasesort() Function in PHP
- ArrayObject ksort() Function in PHP
- PHP | ArrayObject setFlags() Function
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

