user991830
user991830

Reputation: 894

Remove Word using Preg_Replace

I have the following php which pulling back text:

if( $this->sitemap->params->get('show_menutitle') )
echo '<h2 class="menutitle">'.$menu->name.'</h2>';

Each time it runs it pull's back:

About Menu
Support Menu
Contact Menu

I need to remove the text Menu from all instances, but can't figure out the preg_replace to add to the above.

Upvotes: 0

Views: 444

Answers (1)

Niet the Dark Absol
Niet the Dark Absol

Reputation: 324650

You don't need a regex to replace a constant.

echo '<h2 class="menutitle">'.str_replace(" Menu","",$menu->name).'</h2>';

Upvotes: 3

Related Questions