Welcome Guest, Not a member yet? Register   Sign In
Cant request array results
#1

[eluser]Rubiz'[/eluser]
Hello all!!

Well I have a PHP question...

I recorded an array, and I print_r this, the result is:
Code:
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:
Code:
<? 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;">
                &lt;?=$messages['message'][$i]?&gt;
            </div>
            <br /><br />
            &lt;? endif ?&gt;
        &lt;? endfor ?&gt;

    &lt;? endif ?&gt;

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

[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:

Code:
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...
#3

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

[eluser]Rubiz'[/eluser]
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 !!
#5

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




Theme © iAndrew 2016 - Forum software by © MyBB