Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

How do I add to the beginning of an array and find the
number of elements in it?

Answer Posted / 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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Explain the difference between urlencode and urldecode?

1109


What are the rules to determine the “truth” of any value which is not already of the boolean type?

991


What is include in php?

1016


Can php run without server?

1090


Write a select query that will be displayed the duplicated site name and how many times it is duplicated?

1083


What is print_r?

949


What is php variable?

1059


What is csrf token and how will you add csrf token in ajax?

1039


What is crypt () in php?

999


Tell us how to redirect a page in php?

1038


How to get the position of the character in a string in php?

1130


Do you know what is php?

1089


What is mvc? Why its been used?

994


What is $_ post in php?

1128


Php program to generate fibonacci series?

1120