PDA

View Full Version : pass array PHP to Flash - converting string into array in Flash


ckey
01-26-2003, 09:34 PM
As far as i know I have to convert a PHP array to a string which will be converted into an array in Flash again. Thats the reason why I wrote the following in my PHP file:

<?
mysql_connect_ ('localhost' ,_ 'test' ,_ 'test' );_
mysql_select_db_ ('fonts_images' );_
__
$result_ =_ mysql_query_ ("SELECT * FROM fonts_images" );_
$rows_ =_ mysql_num_rows_ ($result );_
__
while_( $list []_=_ mysql_fetch_array_ ($result ));_
__
$output_ =_ "&myval=" ;

for_( $i =0;$i <$rows ;$i ++)
{
$output_ .=_ $list [$i ][ "image_thumb_file" ]. "," .$list [$i ][ "cat_id" ];
$output_ .=_ "|" ;
}
echo_ $output ;
?>

so I get

&myval=1.jpg,2|2.jpg,2|3.jpg,1 etc.
(*.jpg is the path of the file and the second thing is the cat_id)

So I can perfectly adress "myval" in Flash after using loadVariables

loadVariables (" select_2.php ", _root );

how can I convert the string into an array again using actionscript and how have the values be adressed (text field should display the cat_id - just using my_array[1] e.g.?)

thanks, ckey

jimburton
01-27-2003, 09:32 AM
myArray = myval.split("|");