|
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 |
williamf Smarty n00b
Joined: 20 May 2020 Posts: 1
|
Posted: Wed May 20, 2020 7:44 pm Post subject: show last item in array |
|
|
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
$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 |
|
bsmither Smarty Elite
Joined: 20 Dec 2011 Posts: 322 Location: West Coast
|
Posted: Thu May 21, 2020 12:37 am Post subject: |
|
|
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 |
|
|
|
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
|