ck1mark Posted April 11, 2006 Share Posted April 11, 2006 i am sending variables from flash 8 to php:$s_arr = $_POST['arr'];i can echo and get what i sent values: x100y100, x110y100but if i do a foreach it is empty, nothing happensforeach($s_arr as $coord){echo "executed";}what can i do? Link to comment https://forums.phpfreaks.com/topic/7086-array-_post-foreach/ Share on other sites More sharing options...
kenrbnsn Posted April 11, 2006 Share Posted April 11, 2006 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 Link to comment https://forums.phpfreaks.com/topic/7086-array-_post-foreach/#findComment-25742 Share on other sites More sharing options...
ck1mark Posted April 11, 2006 Author Share Posted April 11, 2006 [!--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, ..xif i index it $s_arr[0] i get the first letter.. which in my first post was xso i assume it is handling my values as a string Link to comment https://forums.phpfreaks.com/topic/7086-array-_post-foreach/#findComment-25921 Share on other sites More sharing options...
kenrbnsn Posted April 11, 2006 Share Posted April 11, 2006 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 Link to comment https://forums.phpfreaks.com/topic/7086-array-_post-foreach/#findComment-25934 Share on other sites More sharing options...
ck1mark Posted April 11, 2006 Author Share Posted April 11, 2006 crown that mofo! Thanks much =] Link to comment https://forums.phpfreaks.com/topic/7086-array-_post-foreach/#findComment-25941 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.