1<?php
2
3$array = array("size" => "XL", "color" => "gold");
4
5print_r(array_values($array));
6
7?>
1
2<?php
3$array = array("size" => "XL", "color" => "gold");
4print_r(array_values($array));
5?>
6// ["XL","gold"]
7
8
1<?php
2
3function data() {
4 $out[0] = "abc";
5 $out[1] = "def";
6 $out[2] = "ghi";
7 return $out;
8}
9
10$data = data();
11foreach($data as $items){
12 echo $items;
13}
14
1PHP 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
2
3<?php
4$a=array("Name"=>"ankur","Age"=>"25","Country"=>"India");
5print_r(array_values($a));
6?>
7
8Output:
9Array ( [0] => ankur [1] => 25 [2] => India )
10
11for more visit:
12https://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.
13https://www.w3schools.com/php/func_array_values.asp
14
15/*
16I hope it will help you.
17Thank you _/\_
18*/
1$fruits = ["m"=>"banana", "c"=>"Apple" , "a"=>"gray"];
2$newArray = array_values($colors); //new Array with values $fruits array
3echo "<pre>";
4print_r( $newArray );
5
6
7
8//output
9Array
10(
11 [0] => banana
12 [1] => gray
13 [2] => blue
14 [3] => num
15)