|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
cosanikolis Smarty n00b
Joined: 29 Sep 2015 Posts: 3
|
Posted: Tue Sep 29, 2015 10:08 am Post subject: use the substr function correct? |
|
|
Hello,
I use prestashop and i have a variable called $invoice_address.
This variable gives me a block of info:
Address (here we have a <br>)
Orofos (also here)
Name (also here)
Phone (also here)
.... etc
That's i am trying to do is to assign every single row in a different value in order to put some labels in front of every info. So i have made this code:
{assign var="var_address" value="$invoice_address"}
{$var_address|mb_substr:0$invoice_address|strpos:"<br>"+4)}
{assign var="var_orofos" value="$invoice_address"}
{$var_orofos|mb_substr:($invoice_address|strpos:"<br>"+4)$invoice_address|strpos:"<br>"+4)}
{assign var="var_name" value="$invoice_address"}
{$var_name|mb_substr:(($invoice_address|strpos:"<br>"+4)+($invoice_address|strpos:"<br>"+4))$invoice_address|strpos:"<br>"+4)}
it works correctly in 2 first infos but after it don't appears the info correctly.
What i am doing wrong? can somebody help me?
Thanks |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Wed Sep 30, 2015 4:04 am Post subject: |
|
|
{assign var="foo" value="<br>"|explode:$invoice_address}
now $foo is an array you can do what you need. |
|
Back to top |
|
cosanikolis Smarty n00b
Joined: 29 Sep 2015 Posts: 3
|
Posted: Wed Sep 30, 2015 6:52 am Post subject: |
|
|
Please,
Can you give me an example of 2 first items?
{assign var="var_address" value="$invoice_address"}
{$var_address|mb_substr:0Sad$invoice_address|strpos:"<br>"+4)}
{assign var="var_orofos" value="$invoice_address"}
{$var_orofos|mb_substr:($invoice_address|strpos:"<br>"+4)Sad$invoice_address|strpos:"<br>"+4)}
How is the correct code for those?
How can i use your code for those?
Thanks a lot. |
|
Back to top |
|
cosanikolis Smarty n00b
Joined: 29 Sep 2015 Posts: 3
|
Posted: Wed Sep 30, 2015 7:57 am Post subject: |
|
|
I MADE IT!
THANKS A LOT! |
|
Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|