Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8565399
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T17:25:06+00:00 2026-06-11T17:25:06+00:00

In my PHP-side I have an array of associative arrays like so: Array (

  • 0

In my PHP-side I have an array of associative arrays like so:

Array (
   [0] => Array (
         [resultId] => 15
         [testId] => 4
         [accountId] => 35 
         [score] => 50
         [standard_deviation] => 0.5
         [answer_time] => 475.67
         [created_at] => 2012-09-20 01:45:05
         [groupId] => 4 
         [accountName] => hbbgrewkcx 
         [testName] => test1),
   [1] => Array (
         [resultId] => 14
         [testId] => 3
         [accountId] => 35
         [score] => 60
         [standard_deviation] => 0.5
         [average_answer_time] => 386.1
         [created_at] => 2012-09-20 01:44:56
         [groupId] => 4
         [accountName] => hbbgrewkcx
         [testName] => test2)
)

I would like to transfer this array to the javascript side. How can I make the javascript counterpart of this array of associative arrays and access the required values?

Basically I want the same functionality as foreach would give me in PHP:

foreach($ArrayOfArrays as $array)
{
  doSomething $array['testName'];
  doSomething $array['created_at'];
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T17:25:07+00:00Added an answer on June 11, 2026 at 5:25 pm

    All you would have to do essentially is echo out the JavaScript code to the right place on the page.

    echo "<script language='text/javascript'>";
    echo "var myArr = ".json_encode($phpArray).";";
    echo "</script>";
    

    The json_encode() function, returns a JSON representation of a value. JavaScript handles JSON’s very easily so you should be able to access your multidimensional array without problems!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an php array that is generated by server-side code. I want to
I would like to perform the following server-side in PHP... If I have one
If I have something like this from the server side, from a fetch: array(1)
I have a website which works with PHP on the server side. Users access
i have a rhel 4 server and use php as a server side scripting
I have designed a webpage using HTML and client side validation using JavaScript.PHP for
On this site: http://walkman.pk/aserdus2/tagok.php I have two background-images on the left and right side,
Is it possible to return groups as an associative array? I'd like to know
I have to send a byte array (encoded photo) from my PHP client to
I have a PHP String like this: $string = 'a => 1 , b

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.