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
Release: 2023-03-15 15:02:01
Original
2267 people have browsed it

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

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

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!

Related labels:
php
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