Blog de programación, errores, soluciones

Chose Language:
comments
Author: Admin/Publisher |finished | checked

PHP array_values function

The PHP function array_values will return all the values of the array in an indexed array.

Description / Descripción
array_values(array $array): array
Sintaxis / Sintax
$iarray = array_values($array_to_be_processed);

Parameter

$array – This is the array from which we will obtain its values, and it can be an associative array. In fact, this is the situation where the function makes sense.

Return

An indexed array containing the values from the previous array.

Example

$caracteristicas_auto = [
    "marca" => "Toyota",
    "modelo" => "Camry",
    "año" => 2022,
    "color" => "Azul",
    "motor" => "2.5L",
    "tracción" => "Delantera"
];
var_dump(array_values($caracteristicas_auto));
array(6) {
  [0]=>
  string(6) "Toyota"
  [1]=>
  string(5) "Camry"
  [2]=>
  int(2022)
  [3]=>
  string(4) "Azul"
  [4]=>
  string(4) "2.5L"
  [5]=>
  string(9) "Delantera"
}
Category: en-php
Something wrong? If you found an error or mistake in the content you can contact me on Twitter | @luisg2249_luis.
Last 4 post in same category

Comments