How To Use Array Values Function With Example In PHP

admin_img Posted By Bajarangi soft , Posted On 22-09-2020

In PHP array_values() function returns an array containing all the values of an array.

PHP array values function with example

Syntax for PHP array_values() function.

array_values(array)

Parameter   Description

array  Specifying an input array

Example(1)
<?php
$a=array("Name"=>"Radha","Age"=>"41","Country"=>"India");
print_r(array_values($a));
?>

In above example we create new array and we only get values but we wont get key values by uisng array value function .

Complete code for PHP array_values() Function.

<!DOCTYPE html>
<html>
<head>
    <title>PHP array values function with example</title>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">
</head>
<body>
<div class="container">
    <br>
    <br>
    <br>
    <div class="text-center">
        <h1>PHP array values function with example</h1>
    </div>
    <br>
    <br>
    <h2></h2>
    <div class="well">
        <?php
        $a=array("Name"=>"Radha","Age"=>"41","Country"=>"India");
        print_r(array_values($a));
        ?>
    </div>
    <br>
</div>
</body>
</html>

Related Post