• I am trying to take categories with spaces in them, for example, “Politics in Minnesota”, and use the str_replace function to replace the spaces with underscores, like “Politics_in_Minnesota.” this doesn’t work:
    str_replace(" ","_",single_cat_title())
    and this bit of code seems to indicate that nothing comes out of it at all – the “string!” part is just left sitting there by itself, and ‘SPC’ doesn’t replace the spaces.
    <?php $undersc = single_cat_title(); echo $undersc?> into: <?php $undersc2 = 'string!'.str_replace(' ','SPC', $undersc)?> <?php echo $undersc2?>
    I am not very experienced with PHP, is there something I don’t understand here? I realize i could also use the slugs to do something like this but I am curious…

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Combining str_replace() and single_cat_title() to manipulate strings’ is closed to new replies.