Voting

: four minus three?
(Example: nine)

The Note You're Voting On

info at mobger dot de
2 years ago
If you want to rearrage an array with two layers (perhaps from database-requests), then use 'array_walk' instead:

<?php

$yamlList
= [
[
'title' => 'hallo ich', 'identifier' => 'ich', 'Klaus'=> 'doof',],
[
'title' => 'hallo du', 'identifier' => 'du', 'Klaus'=> 'doof',],
[
'title' => 'hallo er', 'identifier' => 'er', 'Klaus'=> 'doof',],
];
echo (
'Input'."\n".print_r($yamlList,true)."\n");
array_walk($yamlList, function (&$value, $key) {
$value = [
$value['title'],
$value['identifier'],
];
});
echo (
"\n".'Output'."\n".print_r($yamlList,true)."\n");
?>

The Result
===========
...
Output
Array
(
[0] => Array
(
[0] => hallo ich
[1] => ich
)

[1] => Array
(
[0] => hallo du
[1] => du
)

[2] => Array
(
[0] => hallo er
[1] => er
)

)

<< Back to user notes page

To Top