Jump to content


Photo

array = $_POST & foreach


  • Please log in to reply
4 replies to this topic

#1 ck1mark

ck1mark
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 11 April 2006 - 03:34 AM

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?

#2 kenrbnsn

kenrbnsn
  • Staff Alumni
  • Advanced Member
  • 8,235 posts
  • LocationHillsborough, NJ, USA

Posted 11 April 2006 - 04:19 AM

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?
<?php echo '<pre>' . print_r($_POST,true) . '</pre>'; ?>

Ken

#3 ck1mark

ck1mark
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 11 April 2006 - 05:54 PM

[!--quoteo(post=363544:date=Apr 10 2006, 11:19 PM:name=kenrbnsn)--][div class=\'quotetop\']QUOTE(kenrbnsn @ Apr 10 2006, 11:19 PM) View Post[/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?
<?php echo '<pre>' . print_r($_POST,true) . '</pre>'; ?>

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

#4 kenrbnsn

kenrbnsn
  • Staff Alumni
  • Advanced Member
  • 8,235 posts
  • LocationHillsborough, NJ, USA

Posted 11 April 2006 - 06:15 PM

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:
<?php $arr = explode(',',$s_arr); ?>
Then you can use the array functions.

Arrays in PHP are very powerful.

Ken

#5 ck1mark

ck1mark
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 11 April 2006 - 06:40 PM

crown that mofo! Thanks much =]




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users