How do I add to the beginning of an array and find the
number of elements in it?
Answer / jude jeevanraj.p
To do this, you will want to use the array_unshift function
which works like this.
<?php
$values = array(2,3,4,5,6,7,8,9,10);
$elements = array_unshift($values,1);
echo "Number of elements: $elements \n\n";
print_r($values);
?>
Here's the output:
Number of elements: 10
Array
(
[0] => 1
[1] => 2
[2] => 3
[3] => 4
[4] => 5
[5] => 6
[6] => 7
[7] => 8
[8] => 9
[9] => 10
)
| Is This Answer Correct ? | 8 Yes | 0 No |
Why we are using PHP than others for web developing?
Is wordpress a php framework?
Tell me what is the difference between ereg_replace() and eregi_replace()?
How to check your php installation?
i have a string and that string contains the alphanumeric value and i want to hide or semihide the 10 digit telephone number from the string.
What is the difference between static and dynamic websites?
Where can I find php ini file?
What’s the special meaning of __sleep and __wakeup?
How to get no. of rows using MYSQL function?
How to turn on the session support in php?
What are the new features in php 7?
Do you know what is the function func_num_args() used for?