Jump to content

Trimming a string


magnetica

Recommended Posts

Hi all

 

Hope you can help. I have a string and I wanted to trim anything that is past the colon ( : ) in the string.

 

E.g.

  $string = "Magnetica: hell this would be a comment";

 

I want to get it so the output is:

 

Magnetica

 

This is my code so far:

 

            $text   = "Magnetica: hello this is a comment";
                var_dump($text); 
            $trimmed = rtrim($text, ":");
                var_dump($trimmed);

 

But this doesn't work, any ideas?

 

Thanks, Magnetica

Link to comment
https://forums.phpfreaks.com/topic/195280-trimming-a-string/
Share on other sites

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.