Menu

Laravel Array PrependKeysWith Helper

Hello guys,
Today we will learn about laravel helper.

Arr::prependKeysWith()

The Arr::prependKeysWith prepends all key names of an associative array with the given prefix:

 

use Illuminate\Support\Arr;
 
$array = [
    'name' => 'Desk',
    'price' => 100,
];
 
$keyed = Arr::prependKeysWith($array, 'product.');
 
/*
    [
        'product.name' => 'Desk',
        'product.price' => 100,
    ]
*/

 It may be helpful in your next/current project.
Please share and follow our social media channels.

Thanks 

1014
Search

Ads