• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Cant request array results

Hello all!!

Well I have a PHP question...

I recorded an array, and I print_r this, the result is:
Array ( [message] => Array ( [0] => Imagem: 2_1.gif inserida com sucesso!
Caminho para inserir no HTML: http://www.bandeirantesgalvanica.com.br/email_sender/img/active/2_11213151136.gif

[1] => Imagem: 5_1.gif inserida com sucesso!
Caminho para inserir no HTML: http://www.bandeirantesgalvanica.com.br/email_sender/img/active/5_11213151136.gif

) )

I forgot how to request this in view...

I tried this way:
<? if(isset($messages)): ?>
        &lt;? for ($i=0; $i < sizeof($messages); $i++): ?&gt;
            &lt;? if (isset($messages['message'][$i])): ?&gt;
            <div style="padding:3px; background-color:#FFFFCC; border:solid 1px #FF9966;">
            <br /><br />
            &lt;? endif ?&gt;
        &lt;? endfor ?&gt;

    &lt;? endif ?&gt;

But if doesnt work... anyone knows the right way?

[eluser]Michael Wales[/eluser]
It appears as if your array is named $message, not $messages.

EDIT: Nevermind, early in the morning for me.
I would just do:

foreach ($messages['message'] as $message => $id) {
  echo $id;

Not seeing all of your code I am curious as to why you are using a multi-dimensional array here though...

[eluser]saidai jagan[/eluser]
yeah use a for each it ll be easy to fix it

I used it, its is right now, thanx!! Smile

Well actually I recorded an array inside a result array, so, of course I would have to make a foreach rsrsrs.

I'm so "silly" sometimes.

I needed to controll result so I made a foreach, switched to a for, and it is working!!

Thanx guys!

PS: Saidai, I loved your profile picture !!

[eluser]saidai jagan[/eluser]
thanx buddy :red:

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.