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 |
Explain what is the main difference between require() and require_once()?
What is Joomla?
What is the use of friend function?
This is regarding file uploading. 1. Who will be the owner of the uploaded file ? 2. What permission you will give for an uploaded file ? 3. What is mean by user, group and others and what kind of permission you will give for each user and explain the reason?
What is static in php?
How can we extract string 'abc.com' from a string "http://info@abc.com" using regular expression of PHP
How big is varchar max?
Is php front end?
Does php have future?
How do you pass a variable by value in php?
How to get a random value from a php array?
What are constructor and destructor in PHP?