1

I find myself frequently outputting PHP Array data into AS3 applications and I'm always having to do it the hard way - comma delimated, base-64 converted data with custom packers/unpackers on either end.

I'd really like an AS3 function that takes the default output of PHP's print_r and converts it to a (potentially nested) AS3 array. Is there any easy way to do this?

Sample Print_r output:

Array
(
    [0] => Array
        (
            [0] => 6
            [1] => Test #1 of the video creation system
            [2] => Short summary of test #1
        )

    [1] => Array
        (
            [0] => 7
            [1] => Tone
            [2] => Bar and Tone to warp the mind
        )

)

2 Answers 2

3

Do you need print_r specifically, or just the contents of the PHP array?

If it's the contents you're after, you could json_encode() the php array, pass that to AS3 and decode it there using the JSON Library for AS3 (part of as3corelib).

If you are after the contents of print_r specifically, could you please explain why?

Sign up to request clarification or add additional context in comments.

Comments

0

You have 3 best choices for transferring Arrays and Objects between PHP and AS3, all of them use AMF format

  1. Zend AMF
  2. amfPHP
  3. Luracast Restler with the AmfFormat

First two use Flash Remoting where as the third one is light weight leveraging HTTP protocol and REST

Best format to use with Flash is AMF because it is binary and thus consuming less bandwidth and AMF is the native format supported by Flash with out the need for any third party decoders

All the above will allow you to get php data as as3 equivalent. Read more aout flash remoting if you want to use the first two. Read this article by Jac Wright if you want to know how you can consume amf data from an RESTful api server

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.