$array = '10,20,30';
$string = 'jhsdfjhsdfjh[]skfjskdfjsdkfjsdkfj[]kjsdfkjsdkfjsdf[]';
what i want is
jhsdfjhsdfjh[10]skfjskdfjsdkfjsdkfj[20]kjsdfkjsdkfjsdf[30]
Is there a secret function to do this. the reason I say this is because sometimes I spend time coding something php already has a function.
this is what i have and works
Code: Select all
$data='abcd:[efgh[]ijkl][]mnop';
$array = array(1,2,3,4);
foreach($array as $d)
{
$pos = strpos($data,'[]');
$data= str_replace('[]',"[$d]",substr($data,0,$pos+2)) . substr($data,$pos+2);
}
echo $data;
Thank you