I have a string 'some value' and I am looking for the function that replaces certain values with another one.
For example I need the
'some value'
to become
'some_value'
This is what I have tried so far with no luck
$newCategory=str_replace(' ', '_', $rows["category"]);
echo $newCategory;
This works fine for me
$rows["category"] = 'some value';
$newCategory=str_replace(' ', '_', $rows["category"]);
echo $newCategory;
Output
some_value
Display errors could be turned off in the php.ini or your apache config file.
You can turn it on in the script and see any error is there
error_reporting(E_ALL);
ini_set('display_errors', 1);
Your code works for me. Still you can give this a try:
$newCategory = preg_replace('/\s+/', '_', $rows["category"]);