In this blog, I will learn you replace pattern in the string sequentially using an array in laravel application. The preg_replace_array function replaces a given pattern in the string sequentially using an array.
Here I will give full example for preg_replace_array function in laravel. So let's see the bellow example.
* The attributes that are mass assignable.
* @var array
public function index()
$string = 'The event will take place between :start and :end';
$replaced = preg_replace_array('/:[a-z_]+/', ['8:30', '9:00'], $string);
// The event will take place between 8:30 and 9:00
The event will take place between 8:30 and 9:00
It will help you...