Hey guys,

I need some help with preg_replace()

I have something like this....

{$gallery_20}

And I want to use preg_replace to replace it with nothing.... however gallery_20 can be anything... but im not sure on the patten...

Can anyone help please?
I don't understand how to change all this.... $patterns = array ('/(19|20)(\d{2})-(\d{1,2})'); (from php.net)

Dan

Recommended Answers

All 3 Replies

$your_string = preg_replace('/\{\$\w+\}/', '', $your_string);

Thanks mate!

How do you know what to put? I couldn't find anything on the web about it :(

Dan

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.