So i am Considering Your Array
$yourArray = [
'Agent' => 'SMITH',
'Customers' => ["Jack", "Mike"],
'Cars' => ["BMW", "Audi"],
'Money' => ["1000$", "1500$"],
];
And Your Expected Output is
$yourExpectedOutPut = 'Agent SMITH sold BMW car to Jack with 1000$ and Audi car to Mike with 1500$';
So first import this to your name space
use IlluminateSupportArr;
$agentName = Arr::get($yourArray, 'Agent');
$customers = Arr::get($yourArray, 'Customers');
$cars = Arr::get($yourArray, 'Cars');
$Money = Arr::get($yourArray, 'Money');
foreach ( $customers as $customerIndex => $customerName)
{
$perparedArray[] = $cars[$customerIndex] . ' car to '. $customerName.' with '. $Money[$customerIndex];
}
$preparedString = 'Agent '. $agentName.' sold '.implode(' and ', $perparedArray);
echo $preparedString;
Agent SMITH sold BMW car to Jack with 1000$ and Audi car to Mike with 1500$
if you have any doubt or found any issues or if the answer is not what you are looking for kindly comment below
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…