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 |
What are soundex() and metaphone() functions in php?
How error handling is being handled by php?
What are the methods of array in java?
What is the correct and the most two common way to start and finish a php block of code?
How do you match the character ^ at the beginning of the string? - ^^
we store and display scores of users in different games. In MySQL, records are stored as tuples (user-id, game-id, score). Now we need to support ranks of users, i.e., each user should be informed of his current rank in the community. The challenge is to come up with the best way to store the data in MySQL so that the requirements are efficiently met.
Explain the syntax for ‘foreach’ loop with example.
In php how can you jump in to and out of "php mode"?
how to upload more than 50 mb? i tried but session was expired....certain time .....i was set session duration three days .... how to rectified? if any one know that post ur answer as soon as possible?already i was increase php.ini and set Also increase Memory_limit Post_max_size upload_max_filesize..........but not working......
Which php framework is fastest?
What is the purpose of the following files having extensions: frm, myd, and myi? What these files contain?
Tell me what sized websites have you worked on in the past?