# Php array into flash array

**URL:** <https://forum.kirupa.com/t/php-array-into-flash-array/262858>\
**Category:** Uncategorized\
**Created:** [June 10, 2008, 4:11pm UTC](https://forum.kirupa.com/t/php-array-into-flash-array/262858 "2008-06-10T16:11:59Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![levidyllan](https://avatars.discourse-cdn.com/v4/letter/l/f08c70/32.png) [@levidyllan](https://forum.kirupa.com/u/levidyllan)\
**Post date:** [June 10, 2008, 4:11pm UTC](https://forum.kirupa.com/t/php-array-into-flash-array/262858/1 "2008-06-10T16:11:59Z")

</div>

Hi guys,

I have this php page that simply reads two items from the db. One is a number and the other is an image name. Now the number is the sequence order of the images. Also it will goven the array number, as the order/sequence of the images are random and following nothing easy, and I cannot alter the db, so using this sequence number I have place the images in an array, using the sequence to order correctly see below:

while($row = mysql\_fetch\_array($result)) {

$theImages[$row[‘sequence’]]=$row[‘img’];  
…

then when i echo these out normally for testing using a for loop see below I get them into the correct order as wanted:

for($i=0; $i\<22; $i++){  
echo ‘\<br /\>\<br /\>\<img src="directory/’ . $theImages[$i+1].’" /\>’;  
echo ‘\<br /\>’ . $theImages[$i+1];  
}

Right now I can get data into flash no problem say like news stories ect but what I want to do here is to place these into a flash array so I can create a simple gallery, that will use the array to go back and forth through the images.

How could I get the info into a flash array to I can manage it with in flash actionscript etc

I hope this is enough info.

Si

---

<div class="post-metadata">

**Author:** ![dthought](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/dthought/32/3573_2.png) [@dthought](https://forum.kirupa.com/u/dthought)\
**Post date:** [June 11, 2008, 2:27am UTC](https://forum.kirupa.com/t/php-array-into-flash-array/262858/2 "2008-06-11T02:27:47Z")

</div>

Parse your PHP into an XML structure, then read that into Flash and parse it back out. It may feel like a little more work, but it will at least keep things clean and structured. Anything like splitting strings is going to be slow, especially if you have a lot of data to work with.

---

<div class="post-metadata">

**Author:** ![cholin](https://avatars.discourse-cdn.com/v4/letter/c/8edcca/32.png) [@cholin](https://forum.kirupa.com/u/cholin)\
**Post date:** [June 11, 2008, 2:55am UTC](https://forum.kirupa.com/t/php-array-into-flash-array/262858/3 "2008-06-11T02:55:55Z")

</div>

I did something similar but I was making a 2-d RPG game and my levels were arrays.

What I did, since my levels were simply numbers, is I added a line separator and a number separator.  
My format was like  
1$2$3$4…$9|  
123$456$789|

Then I just split the strings in Flash because when you split a string it automatically makes an array…  
quick as hell and perfect.

---

<div class="post-metadata">

**Author:** ![levidyllan](https://avatars.discourse-cdn.com/v4/letter/l/f08c70/32.png) [@levidyllan](https://forum.kirupa.com/u/levidyllan)\
**Post date:** [June 11, 2008, 7:15pm UTC](https://forum.kirupa.com/t/php-array-into-flash-array/262858/4 "2008-06-11T19:15:26Z")

</div>

thanks guys, decided to go with the xml version and go into that direction, will post up my solution if working for others or simply another problem question 🙂

si
