Page 1 of 1

How To Get All the Values Out of an Array?

Posted: Sat Oct 01, 2016 5:34 pm
by deepak singh
How To Get All the Values Out of an Array?

Re: How To Get All the Values Out of an Array?

Posted: Sat Oct 01, 2016 5:35 pm
by rameshkhd
F unction array_values() returns a new array that contains all the keys of a given array. Here is a PHP script on how to use array_values():
<?php
$mixed = array();
$mixed["Zero"] = "PHP";
$mixed[1] = "Perl";
$mixed["Two"] = "Java";
$mixed["3"] = "C+";
$mixed[""] = "Basic";
$mixed[] = "Pascal";
$mixed[] = "FORTRAN";
$values = array_values($mixed);
print("Values of the input array:\n");
print_r($values);
?>
This script will print:
Values of the input array:
Array
(
[0] => PHP
[1] => Perl
[2] => Java
[3] => C+
[4] => Basic
[5] => Pascal
[6] => FORTRAN
)