PHP Questions Home
Categories
Arrays
Files
Forms
Creating PDFs
PHP Errors
Functions
Images
MySQL
Numbers
Others
Strings
Website

PHP Forums
Forums Index
MySQL Forum
PHP Forum
Flash/Actionscript
Javascript
Web design

More PHP
PHP Functions
Top Questions
Ask a Question
PHP Interview Questions
PHP Jobs
Ecommerce
IT Questions
Business Websites

Sponsors

sponsor ad
My Salary
PHP Developer Salary
Advertise Here

How do I return all the values in an array?


Sometimes the relationship between the key and the value in an array will be of importance to us, but often that is not the case and all we really want to concentrate on are the values in the array.

For times like this, PHP provides us with the array_values function, which will simply return is an array containing the values, like so:

<?php
$example 
= array(572=>"i","don't","care","much","for","keys");
print_r($example);
$values array_values($example);
print_r($values);
?>


Which prints:

Array
(
[572] => i
[573] => don't
[574] => care
[575] => much
[576] => for
[577] => keys
)
Array
(
[0] => i
[1] => don't
[2] => care
[3] => much
[4] => for
[5] => keys
)

You can see that the keys from the initial array are gone, but if we weren't interested in those then that's just fine!



ASK A QUESTION

More arrays PHP Questions

What is the starting salary of Php developer in india?? after 1 year experience how much i could get??

i have a site named profile.php where i want to replace the following: http://www.youtube.com/watch?v=yoXE031j8d0 into: i know i could use str_replace to replace into ... but i need to know the URL so i can check if it rea

when we retrieve values from db and show in drop-down list then how can i get selected particular value from drop-down so that programe will go next page??

I have an array of numbers and many repeat, how to list all items in order of maximum occurence?

How do I pick a random value from an array?



Custom Search