- str_replace: documentation ( source)
- sprintf: documentation ( source)
<?php
$espn_ar["pid_6254"] = "2977742";
$espn_ar["pid_8269"] = "9614";
foreach ($espn_ar as $key => $value) {
$imageName = sprintf('images/mfl_%s.png', str_replace('pid_', '', $key));
echo $imageName, PHP_EOL;
}