Issue
I have the title ( Architectural_Garden_Hardware-Switch Plates & Outlet Covers )
But i whant show only the characters after dash ( - ) like ( Switch Plates & Outlet Covers )\
How can do that?
{foreach from=elements item=birds}
<option value="{$birds}">{$birds}</option>
/foreach}
Solution
You should use strpos and substr as in the following example:
{assign var="var" value=" ( Architectural_Garden_Hardware-Switch Plates & Outlet Covers )"}
{assign var="pos" value=$var|strpos:"-"}
{$var|substr:($pos+1)}
You could also use shorter syntax:
{assign var="var" value=" ( Architectural_Garden_Hardware-Switch Plates & Outlet Covers )"}
{$var|substr:($var|strpos:"-"+1)}
so in your case you could probably use:
{foreach from=elements item=birds}
<option value="{$birds|substr:($birds|strpos:"-"+1)}">{$birds|substr:($birds|strpos:"-"+1)}</option>
{/foreach}
Answered By - Marcin NabiaĆek Answer Checked By - Mary Flores (PHPFixing Volunteer)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.