Jump to content

trimming and replacing at the same time


dennismonsewicz

Recommended Posts

What do you want to do?  Trim the whitespace form the end and beginning of the string and then replace the "left over" whitespace with whatever, say _?

 

If that is the case I don't think there is a function for that but you can just do somethng like this

 

<?php
$string = "yourstring";

$newstring = str_replace(" ", "_", trim($string));

?>

 

Not sure if that is what you are looking for.

 

Nick

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.