Smarty Forum Index Smarty
The discussions here are for Smarty, a template engine for the PHP programming language.

use the substr function correct?

 
Post new topic   Reply to topic    Smarty Forum Index -> Smarty Development
View previous topic :: View next topic  
Author Message
cosanikolis
Smarty n00b


Joined: 29 Sep 2015
Posts: 3

PostPosted: Tue Sep 29, 2015 10:08 am    Post subject: use the substr function correct? Reply with quote

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: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)}

{assign var="var_name" value="$invoice_address"}

{$var_name|mb_substr:(($invoice_address|strpos:"<br>"+4)+($invoice_address|strpos:"<br>"+4))Sad$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
View user's profile Send private message
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7364
Location: Lincoln Nebraska, USA

PostPosted: Wed Sep 30, 2015 4:04 am    Post subject: Reply with quote

{assign var="foo" value="<br>"|explode:$invoice_address}

now $foo is an array you can do what you need.
Back to top
View user's profile Send private message Visit poster's website
cosanikolis
Smarty n00b


Joined: 29 Sep 2015
Posts: 3

PostPosted: Wed Sep 30, 2015 6:52 am    Post subject: Reply with quote

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
View user's profile Send private message
cosanikolis
Smarty n00b


Joined: 29 Sep 2015
Posts: 3

PostPosted: Wed Sep 30, 2015 7:57 am    Post subject: Reply with quote

I MADE IT!

THANKS A LOT!
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Smarty Forum Index -> Smarty Development All times are GMT
Page 1 of 1

 
Jump to:  
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
Protected by Anti-Spam ACP