Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

show last item in array

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Smarty Development
View previous topic :: View next topic  
Author Message
williamf
Smarty n00b


Joined: 20 May 2020
Posts: 1

PostPosted: Wed May 20, 2020 7:44 pm    Post subject: show last item in array Reply with quote

i'm really having the worst time trying to figure this out. i've tried a million different things but the truth is my syntax game is weak. I have an array of three items, but i only need to show the value of the mac address. please see my debug info below. I just need to print this one little thing to a div to show the user their mac address. i'm kind of tired of beating my head against the wall Sad

$productcustomfields
Origin: "Smarty object"
Value
Array (3)
0 => Array (10)
id => 1
textid => "username"
name => "Username"
description => "Leave it empty for auto generated"
type => "text"
input => "<input type="text" name="customfield[1]" id="customfield1" value="" size="30"..."
value => ""
rawvalue => ""
required => ""
adminonly => ""
1 => Array (10)
id => 2
textid => "password"
name => "Password"
description => "Leave it blank to Auto Generate Random Chars"
type => "password"
input => "<input type="password" name="customfield[2]" id="customfield2" value="" size=..."
value => ""
rawvalue => ""
required => ""
adminonly => ""
2 => Array (10)
id => 7
textid => "macaddress"
name => "MAC Address"
description => "This is only for users with a MAC address"
type => "text"
input => "<input type="text" name="customfield[7]" id="customfield7" value="00:00:00:00..."
value => "00:00:00:00:1A"
rawvalue => "00:00:00:00:1A"
required => ""
adminonly => ""
Back to top
View user's profile Send private message
bsmither
Smarty Elite


Joined: 20 Dec 2011
Posts: 322
Location: West Coast

PostPosted: Thu May 21, 2020 12:37 am    Post subject: Reply with quote

Try this experiment:
Code:
{$array1 = [["textid"=>"username"],["textid"=>"password"],["textid"=>"macaddress"]]}

<pre>
{$array1|print_r:true}
{foreach $array1 as $k => $v}{if $v.textid == "macaddress"}{$hit = $k}{break}{/if}{/foreach}
{$array1.$hit|print_r:true}
</pre>
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    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