How to use array values in PHP

In this article, I will explain how the array_values() function can be used in PHP.
  • 1928

array_values() function in PHP

  • The array_values() function is used to returns an array containing all the values from an array.

  • The array_values() function returned array will have numeric keys, starting at 0 and increase by 1.

Syntax

array_values(array)

Parameter

  • array  array is required parameter. Specifies an array.

Example

The following example show to how the array_values() function can be used in PHP.

<html>

<body>

<h3 style="color: darkorchid;">array_values() function example in PHP</h3>

    <?php

    $a=array("a"=>"Student","b"=>"Engg.","c"=>"Worker");

    print_r(array_values($a));

    ?>

</body>

</html>

 

Output

values.jpg

You may also want to read these related articles here
 
Ask Your Question 
 
Got a programming related question? You may want to post your question here
 

Categories

More Articles

© 2020 DotNetHeaven. All rights reserved.