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?



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

Post New Answer

More PHP Interview Questions

What is the difference between Split and Explode in PHP?

0 Answers   B-Ways TecnoSoft,


What are the features of php?

0 Answers  


What are new features in php 7?

0 Answers  


In php how can you jump in to and out of "php mode"?

0 Answers  


how long a default session stay in php?

8 Answers  


Tell me what are the functions to be used to get the image's properties (size, width and height)?

0 Answers  


How to create a text file in PHP?

0 Answers  


Is it possible to use com component in php?

0 Answers  


Who created numbers?

0 Answers  


what is the use of include_once in php?

0 Answers  


Tell me how to set a page as a home page in a php based site?

0 Answers  


What is a php certification?

0 Answers  


Categories