Home >Backend Development >PHP Problem >How to set the array in php without the original key name

How to set the array in php without the original key name

WBOY
WBOYOriginal
2022-03-09 10:18:182237browse

In PHP, you can use the "array_values" function to set the array without key names. This function is used to return an array containing all the values ​​in the array. The returned array will remove the original key names and use numerical keys. The syntax is "array_values(array)".

How to set the array in php without the original key name

The operating environment of this article: Windows 10 system, PHP version 7.1, Dell G3 computer.

How to set an array in php without the original key name

array_values() function returns an array containing all the values ​​in the array.

The returned array will use numeric keys, starting from 0 and increasing by 1.

Syntax

array_values(array)

Return value: Returns an array containing all the values ​​in the array.

Examples are as follows:

<?php
$a=array("Name"=>"Peter","Age"=>"41","Country"=>"USA");
print_r(array_values($a));
?>

Output results:

How to set the array in php without the original key name

## Recommended learning: "

PHP Video Tutorial

The above is the detailed content of How to set the array in php without the original key name. 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