Home  >  Article  >  Backend Development  >  How to use array_values ​​function in php

How to use array_values ​​function in php

藏色散人
藏色散人Original
2019-05-24 15:34:024099browse

Usage of array_values ​​function in php: [array_values(array)]. The array_values ​​function is used to return an array containing all key values ​​​​in the given array, without retaining the key names.

How to use array_values ​​function in php

php The array_values ​​function returns all values ​​(non-key names) of the array. Its syntax is array_values(array). The parameter array is required and refers to the specified array.

(Recommended tutorial: php video tutorial)

How to use the php array_values ​​function?

Function: Return all values ​​​​(non-key names) of the array

Syntax:

array_values(array)

Parameters:

array required. Specifies an array.

Description:

Returns an array containing all key values ​​​​in the given array, but does not retain the key names. The returned array will use numeric keys, starting at 0 and increasing by 1.

php array_values() function usage example 1

<?php
$a = array("class" => "php中文网","name" => "西门","job" => "讲师");
print_r(array_values($a));
?>

Output:

Array ( [0] => php中文网 [1] => 西门 [2] => 讲师 )

php array_values() function usage example 2

<?php
$a = array("class" => "php中文网","name" => "无忌哥哥","job" => "考官");
print_r(array_values($a));
?>

Output:

Array ( [0] => php中文网 [1] => 无忌哥哥 [2] => 考官 )

The above is the detailed content of How to use array_values ​​function in php. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn