Reputation: 1383
$x = 1;
if (isset($locats))
{
foreach ($locats as $l)
{
${"variable$x"} = new LatLng(['lat' => $l['google_map_lat'], 'lng' => $l['google_map_lng']]);
${"marker$x"} = new Marker([
'position' =>$variable."$x" ,
'title' => $l['name'],
]);
$x++;
}
}
i want join 2 varibale and use that in one variable!
in :
'position' =>$variable."$x" ,
i want set $variable1 and in next time $variable2 and .... for position
Upvotes: 1
Views: 22
Reputation: 16963
Use variable variables, like this:
$variable = "variable" . $x;
And use it like this:
$$variable // would give $variable1, $variable2 etc.
Upvotes: 1