Can't get str_replace() to strip out spaces in a PHP string -


hi, getting php string need strip spaces out of. have used following code when echo $classname displays string still spaces in it.

   <?php      $fieldname = the_sub_field('venue_title');      $classname = str_replace(' ', '', $fieldname);      echo $classname;    ?> 

if know white space only due spaces, can use:

$classname = str_replace(' ','',$fieldname );  

but if could due space, can use:

$classname = preg_replace('/\s+/','',$fieldname ) 

Comments

Popular posts from this blog

Change php variable from jquery value using ajax (same page) -

Pull out data related to my apps from Android Play Store and iOS App Store -

How can I fetch data from a web server in an android application? -