tags:

views:

76

answers:

2

I have the following code:

{$product.name}

This outputs all of our products, unfortunatly they are stored in the database as 'CompanyNameProductName'.

I want to remove the string 'CompanyName' from the string $product.name

How can I do this in PHP?

+2  A: 

.

$str = str_replace('CompanyName','',$str);

http://at2.php.net/str_replace

Prot0
You sure live up to your gravatar. :)
bzlm
+1  A: 

Replace

{$product.name}

by

{$product.name|replace:'CompanyName':''|capitalize}

This way you can do it in your Smarty template without having to modify your PHP.

JochenJung
Is there any decent Smarty resources cheatsheets?
danit
Also after removing CompanyName I need to capitalise first new letter.
danit
Just added the capitalitze modifier. See here (http://www.smarty.net/manual/en/language.modifiers.php) for a list of smarty modifiers
JochenJung