replacing spaces within a string
-
I have the following within a single post template to bring in an image based on the value of a custom field (named Model). It works fine apart from the spaces within the image name that I would like replacing with underscores. I have been playing around with str_replace but can’t seem to get it to work.
<img src="../../../images/buyers-guide/<?php $model = str_replace(" ","_","Model"); echo get_post_meta($post->ID, $model, true); ?>.jpg" />
I am a bit of a novice with PHP so please be nice!
Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
- The topic ‘replacing spaces within a string’ is closed to new replies.