begineeeerrrr begineeeerrrr -3 years ago 184
PHP Question

Laravel, how to change array key permanently?

Tried using array_values but it only temporary.

controller

foreach($rows as $key => $value)
{
array_values($value);
//dd shows the key changes to [0], [1], [2] and so on
}


enter image description here

Answer Source

You can do it like this,

$rows = array_map(function($v){return array_values($v);}, $rows);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download