<?php
$data = [
['name' => 'name', 'value' => 'Naomi'],
['name' => 'password', 'value' => 'test123456'],
['name' => 'email', 'value' => 'naomitest@gmail.com'],
['name' => 'code', 'value' => 'test123456@test123456'],
['name' => 'phone', 'value' => 423523545435]
];
$data = new ArrayObject(
array_combine(
array_column($data, 'name'),
array_column($data, 'value')
)
);
$data->setFlags(ArrayObject::STD_PROP_LIST|ArrayObject::ARRAY_AS_PROPS);
echo $data->name; // Naomi
echo $data['name']; // Naomi
preferences:
50.88 ms | 405 KiB | 5 Q