juliand665
0
Q:

array values php

array_values(array)
1

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

0
<?php

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

$data = data();
foreach($data as $items){
    echo $items;
}
1
<?php
  
$array = array("size" => "XL", "color" => "gold");

print_r(array_values($array));

?>
0
PHP array_values() is an inbuilt function that returns all the values of an array and not the keys. The array_values() function returns the array containing all the values of an array. The returned array will have the numeric keys, starting at 0 and increase by 1

<?php
$a=array("Name"=>"ankur","Age"=>"25","Country"=>"India");
print_r(array_values($a));
?>
  
Output:
Array ( [0] => ankur [1] => 25 [2] => India )
  
for more visit: 
https://appdividend.com/2019/05/09/php-array-values-example-php-array_values-function-tutorial/#:~:text=PHP%20array_values()%20is%20an,0%20and%20increase%20by%201.
https://www.w3schools.com/php/func_array_values.asp

/*
I hope it will help you.
Thank you _/\_
*/
0
$cars = array(array("Volvo", 22, 18), array("BMW", 15, 13), array("Saab", 5, 2), array("Land Rover", 17, 15));
$cars = array( //Same thing as above execept it is more readable
	array("Volvo", 22, 18),
	array("BMW", 15, 13),
	array("Saab", 5, 2),
	array("Land Rover", 17, 15)
);

echo $cars[0][0] . ", " . $cars[0][1]; //Outputs: Volvo, 22
0

New to Communities?

Join the community