0

i would like to get data out of this multidimensional-array:

Array
(
    [result] => success
    [source] => getLatestConsoleLogs
    [success] => Array
        (
            [0] => Array
                (
                    [time] => 1324301613
                    [line] => 2011-12-19 17:33:33 [INFO] [JSONAPI] [API Call] 0:0:0:0:0:0:0:1: method=getLatestConsoleLogs?args=[]

                )

            [1] => Array
                (
                    [time] => 1324301613
                    [line] => 2011-12-19 17:33:33 [INFO] [JSONAPI] [API Call] 0:0:0:0:0:0:0:1: method=getLatestConsoleLogs?args=[]

                )

            [2] => Array
                (
                    [time] => 1324301613
                    [line] => 2011-12-19 17:33:33 [INFO] [JSONAPI] [API Call] 0:0:0:0:0:0:0:1: method=getLatestConsoleLogs?args=[]

                )

            )
    )

i would be nice, if somehow it could be extracted to div`s. thanks.

4
  • What you want to get out out the array? Commented Dec 20, 2011 at 7:27
  • actually it`ll be best, if I could get all data out :) Commented Dec 20, 2011 at 7:30
  • I would recommend you having some time in learning basic php, rather than using stackoverflow users as your tutors. Commented Dec 20, 2011 at 7:39
  • well, I know basic PHP, but I allways have problems with arrays. Commented Dec 20, 2011 at 7:44

2 Answers 2

1

You can just use a normal foreach loop like this:

$successes = $array['success'] /* where $array is the variable holding the result */
foreach($successes as $success) {
    echo "<div>Time: " . $success['time'] . " - Line: " . $success['line'] . "</div>";
}
Sign up to request clarification or add additional context in comments.

Comments

1

You can so json_encode() to convert your array to JSON and then use javascript to place those in appropriate div's

OR if you want to do it on server side, you can check this

http://www.terrawebdesign.com/multidimensional.php

2 Comments

then whats coming to your way? you can simply place them! what's stopping you?
then I have updated the answer for you, check if this works for you!

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.