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 7415075
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T07:13:36+00:00 2026-05-29T07:13:36+00:00

suppose I have the follwing matrix data: 2 3 4 5 6 7 8

  • 0

suppose I have the follwing matrix data:

 2  3  
 4  5 
 6  7
 8  9

How to insert them into a 2d php array, can anybody help me with that, I am new to php 2d array, any help will be greatly appreciated!

  • 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-05-29T07:13:37+00:00Added an answer on May 29, 2026 at 7:13 am

    Do you actually want a 2D array or do you want your first columns to be the keys?

    You can do this:

    $key = 2;
    $value = 3;
    $array[$key] = $value;
    echo '<pre>'; print_r( $array ); echo '</pre>';
    // outputs  array( [2] => 3 )
    

    Then you can access it like this:

    foreach( $array as $key => $value ){
        echo $key.' - '.$value.' <br />';
    }
    // outputs: 2 - 3
    

    You can also do this:

     $array[] = array( '2', '3' );    
     $array[] = array( '4', '5' );    
     // outputs  
          array( [0] => array( 
                         [0] => 2,
                         [1] => 3 )
                 [1] => array( 
                         [0] => 4,
                         [1] => 5 )
               )
    

    Read this and post back with a more specific question if you are not understanding somewhere.
    https://www.php.net/manual/en/language.types.array.php

    Also, the reason the comments are asking you where you got the data is because you can automate much of this process. If you are pulling it from a database, then the 2D arrays can be made automatically. Otherwise, the process I just did above is very manual. I don’t know think I’ve ever made an array like this in a production environment. They are always in for or foreach loops.

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

Sidebar

Related Questions

Suppose we have the following table data: ID parent stage submitted 1 1 1
Suppose I have the following types of data: class Customer { String id; //
Suppose I have the following matrix: 01 02 03 06 03 05 07 02
Let's suppose I have a numpy matrix variable called MATRIX with 3 coordinates: (x,
Suppose I have following data in my game. I have developed game in cocos2d.
Suppose we have following function in PHP: public function testSomething() { $name = perform_sql_query("SELECT
Suppose I have the following array $diff . a, a, a, a, b, b,
suppose I have a string like the follwing: 01,03,02,15|05,04,06,10|07,09,08,11|12,14,13,16 How to convert it to
Suppose i have following code Rectangle rect = new Rectangle(); lock(rect) { ---- ---
I have following problem where I have to group different transactions into timeslots. Suppose

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.