I am trying to manipulate string when the come for a db query.
i can seem to replace the underscores i use and then make the first letters upper case but what i can’t seem to do is replace some strings with the all upper equiv.
ex. i want to replace Fox or Cnn with FOX and CNN; this is what i have so far that doesnt seem to work with preg or ereg_replace:
[code=php]
$name_torep = array(“cnn”, “fox”);
$name_rep = array(“CNN”, “FOX”);
while($row = mysql_fetch_assoc($result))
{
foreach($row as $key => $value)
{
echo “<option value='”.$value.”‘>”;
$new_value = preg_replace($name_torep, $name_rep, ucwords(str_replace(“_”, ” “, $value)));
echo $new_value.”</option>n”;
}
}
by using ereg_replace, i only get Cnn or Fox but not CNN or FOX – in the db, all my strings are lowercase and spaces are seperated by “_”.
? ?