Jump to content

Archived

This topic is now archived and is closed to further replies.

ck1mark

array = $_POST & foreach

Recommended Posts

i am sending variables from flash 8 to php:
$s_arr = $_POST['arr'];

i can echo and get what i sent values: x100y100, x110y100

but if i do a foreach it is empty, nothing happens
foreach($s_arr as $coord){
echo "executed";
}

what can i do?

Share this post


Link to post
Share on other sites
Is $_POST['arr'] an array or is it a string?

If you put the following line at the beginning of your script, what is displayed?
[code]<?php echo '<pre>' . print_r($_POST,true) . '</pre>'; ?>[/code]

Ken

Share this post


Link to post
Share on other sites
[!--quoteo(post=363544:date=Apr 10 2006, 11:19 PM:name=kenrbnsn)--][div class=\'quotetop\']QUOTE(kenrbnsn @ Apr 10 2006, 11:19 PM) [snapback]363544[/snapback][/div][div class=\'quotemain\'][!--quotec--]
Is $_POST['arr'] an array or is it a string?

If you put the following line at the beginning of your script, what is displayed?
[code]<?php echo '<pre>' . print_r($_POST,true) . '</pre>'; ?>[/code]

Ken
[/quote]

I dont know how to get a result for that in flash.
I dont think i like php arrays!
I send an array and when i echo $s_arr i get the whole array element1, element2, element3, ..x
if i index it $s_arr[0] i get the first letter.. which in my first post was x

so i assume it is handling my values as a string

Share this post


Link to post
Share on other sites
I don't use Flash, so I don't know how it is sending stuff back.

It looks like you're getting a CSV string returned to your script. To turn it into an array, use the explode() function:
[code]<?php $arr = explode(',',$s_arr); ?>[/code]
Then you can use the array functions.

Arrays in PHP are very powerful.

Ken

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.