Basically, I want to use both $city_name
and $ref_name
with str_replace(), so that if either one (or both) of them are inputted by the user, both of them are replaced with their actual variable forms.
To give a better illustration, here's my current code;
$headlines = array('primary_headline' => $_POST['primary_headline'], 'secondary_headline' => $_POST['secondary_headline'], 'primary_subline' => $_POST['primary_subline'], 'secondary_subtext' => $_POST['secondary_subtext']);
$city_name = "Dallas";
$ref_name = "Facebook";
if(isset($headlines)) {
foreach($headlines as $headline) {
echo(str_replace('$city_name', $city_name, $headline));
}
}
I'd basically like str_replace('$city_name', $city_name, $headline)
to become str_replace('$city_name' AND/OR '$ref_name', $city_name AND/OR $ref_name, $headline)
.
Any answers or comments will be greatly appreciated!
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…