Jump to content

Archived

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

dagnasty

Removing the character and everything before it in it's first occurance?

Recommended Posts

So let's say I have this string:

[Movies - Comedy] The Funny Movie [DVD]

and I want to remove first occurance of ] and everything before it, how would I go about doing it so that it leaves me

The Funny Movie [DVD]

?

strstr leaves the ] behind

Share this post


Link to post
Share on other sites
[code]<?php
$string = '[Movies - Comedy] The Funny Movie [DVD]';
echo $string = preg_replace('/^[^]]+\]\s*/', '', $string);
?>[/code]

Share this post


Link to post
Share on other sites

×

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.