I have an associative array of links like this
$my_links = [
'city 1' => 'http://link1',
'city 2' => 'http://link2',
'Head Office' => 'http://link3'
];
and some html like this. The html is dynamically generated by a script ( wordpress blog content).
<p>
You can visit our stores at City 1
and City 2,
or visit our Head office.
</p>
Required Output: Make clickable links using indices of above array
<p>
You can visit our stores at <a href="http://link1">City 1</a>
and <a href="http://link2">City 2</a>,
or visit our <a href="http://link3">Head office</a>.
</p>
How to achieve this using PHP and/or JQuery?
<p> You can visit our stores at <a href="<?php echo $my_links['city 1'];?>">City 1</a> and <a href="<?php echo $my_links['city 2'];?>">City 2</a>, or visit our <a href="<?php echo $my_links['Head Office'];?>">Head office</a>. </p>