array values php code example

Example 1: array values php

<?php
  
$array = array("size" => "XL", "color" => "gold");

print_r(array_values($array));

?>

Example 2: php get all values from array

array_values(array)

Example 3: php array_values

<?php
$array = array("size" => "XL", "color" => "gold");
print_r(array_values($array));
?>
// ["XL","gold"]

Example 4: array php

<?php
$array = array(
    "foo" => "bar",
    "bar" => "foo",
);

// as of PHP 5.4
$array = [
    "foo" => "bar",
    "bar" => "foo",
];
?>

Example 5: array php

<?php
$array = array(
    "foo" => "bar",
    "bar" => "foo",
);

// as of PHP 5.4
$array = [
    "foo" => "bar",
    "bar" => "foo",
];
?>

Example 6: php return array

<?php

function data() {
    $out[0] = "abc";
    $out[1] = "def";
    $out[2] = "ghi";
    return $out;
}

$data = data();
foreach($data as $items){
    echo $items;
}

Tags:

Php Example