Welcome Guest, Not a member yet? Register   Sign In
Cant load vars to view
#11

[eluser]tomcode[/eluser]
Ouf !
#12

[eluser]TheFuzzy0ne[/eluser]
That's not the same as the array you posted initially. Smile

[quote author="bullspit" date="1242347470"]
Array
(
[amt_us] => 59.95
[type] => GPRS
[dealer] => 999
[name] => Unlimited
[desc] => Unlimited Service Plan, Unlimited amount of monthly locates.
[locates] => Unlimited
[id] => 1025
[country] => US
[currency] => USD
[vatrate] =>
[languagecode] => en-US
[currency_symbol] => $
)
[/quote]
#13

[eluser]RJ[/eluser]
that was 2 1/2 hours, i owe you guys a drink
#14

[eluser]TheFuzzy0ne[/eluser]
3 1/2 by my count Smile

I don't get it. You solved you're own problem, I was just bitching over a technicality. Tongue
#15

[eluser]RJ[/eluser]
hmmm... this just doesn't like me for some reason!!! I'm working with the array below.
Quote:Array
(
[0] => Array
(
[amt_us] => 59.95
[type] => GPRS
[dealer] => 999
[name] => Unlimited
[desc] => Unlimited Service Plan, Unlimited amount of monthly locates.
[locates] => Unlimited
[id] => 1025
[country] => US
[currency] => USD
[vatrate] =>
[languagecode] => en-US
[currency_symbol] => $
[amt_sign] =>
)

[1] => Array
(
[amt_us] => 39.95
[type] => GPRS
[dealer] => 999
[name] => Professional
[desc] => The professional plan is a perfect choice to track a device on a consistant basis. Plenty of locates for you to keep an eye on what matters most.
[locates] => 7500
[id] => 1032
[country] => US
[currency] => USD
[vatrate] =>
[languagecode] => en-US
[currency_symbol] => $
[amt_sign] =>
)

[2] => Array
(
[amt_us] => 29.95
[type] => GPRS
[dealer] => 999
[name] => Standard
[desc] => Standard Service Plan, up to 1500 total locates per month.
[locates] => 1500
[id] => 1033
[country] => US
[currency] => USD
[vatrate] =>
[languagecode] => en-US
[currency_symbol] => $
[amt_sign] =>
)

and accessing this way:
Code:
foreach ($locates as $key => $value) {
        foreach ($value as $print_name => $print) {?>
        <?php //$$print_name = $print; ?> // temp commented out to trouble shoot
        <h3 class="headtextl">&lt;?= value['name'] ?&gt;</h3>
&lt;?= }} ?&gt;

But it doesn't seem to be working properly. The $name rotates from the same array over and over again, rather than going through each one. any ideas wth im doing wrong now?
#16

[eluser]TheFuzzy0ne[/eluser]
You just want a list of names?

Code:
&lt;?php foreach ($locates as $arr): ?&gt;
        <h3 class="headtextl">&lt;?= $arr['name'] ?&gt;</h3>
&lt;?php endforeach ?&gt;

I'd recommend having your model pass back the data in the format you want, though.
#17

[eluser]tomcode[/eluser]
Iterating example :

Code:
&lt;?php

foreach ($locates as $row_key => $row) :

?&gt;
<h3>Row number : &lt;?= $row_key ?&gt;</h3>
&lt;?php

        foreach ($row as $key => $value) :

?&gt;
        <p>this is the key : &lt;?= $key ?&gt;
        <br />this is the value :  &lt;?= $value ?&gt;</p>
&lt;?php

        endforeach;
endforeach;

?&gt;
#18

[eluser]RJ[/eluser]
I'll do that, and this worked; so you dont recommend having
Code:
&lt;?php foreach ($locates as $key ):?&gt;
in the view?
#19

[eluser]tomcode[/eluser]
No, no, of course You do not need $row_key, without the loop's probably even faster, I just wanted to give You an example how to iterate such a nested array.

When iterating I take care to name the variables in a way that they'll make sense and I keep an 'airy' notation, views tend to get crowded.




Theme © iAndrew 2016 - Forum software by © MyBB