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

How to use array_values ​​function in php

藏色散人
Release: 2023-02-22 18:10:01
Original
4108 people have browsed it

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)
Copy after login

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));
?>
Copy after login

Output:

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

php array_values() function usage example 2

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

Output:

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

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template