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

The Archive Base Latest Questions

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

For example, I have multidimensional array as below: $array = array ( 0 =>

  • 0

For example, I have multidimensional array as below:

$array = array (
  0 => 
    array (
      'id' => '9',
      'gallery_id' => '2',
      'picture' => '56475832.jpg'
    ),
  1 => 
    array (
      'id' => '8',
      'gallery_id' => '2',
      'picture' => '20083622.jpg'
    ),
  2 => 
    array (
      'id' => '7',
      'gallery_id' => '2',
      'picture' => '89001465.jpg'
    ),
  3 => 
    array (
      'id' => '6',
      'gallery_id' => '2',
      'picture' => '47360232.jpg'
    ),
  4 => 
    array (
      'id' => '5',
      'gallery_id' => '2',
      'picture' => '4876713.jpg'
    ),
  5 => 
    array (
      'id' => '4',
      'gallery_id' => '2',
      'picture' => '5447392.jpg'
    ),
  6 => 
    array (
      'id' => '3',
      'gallery_id' => '2',
      'picture' => '95117187.jpg'
    )
);

How can I get key of array(0,1,2,3,4,5,6)?

I have tried a lot of examples, but nothing has worked for me.

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

    This is quite simple, you just need to use array_keys():

    $keys = array_keys($array);
    

    See it working

    EDIT For your search task, this function should do the job:

    function array_search_inner ($array, $attr, $val, $strict = FALSE) {
      // Error is input array is not an array
      if (!is_array($array)) return FALSE;
      // Loop the array
      foreach ($array as $key => $inner) {
        // Error if inner item is not an array (you may want to remove this line)
        if (!is_array($inner)) return FALSE;
        // Skip entries where search key is not present
        if (!isset($inner[$attr])) continue;
        if ($strict) {
          // Strict typing
          if ($inner[$attr] === $val) return $key;
        } else {
          // Loose typing
          if ($inner[$attr] == $val) return $key;
        }
      }
      // We didn't find it
      return NULL;
    }
    
    // Example usage
    $key = array_search_inner($array, 'id', 9);
    

    The fourth parameter $strict, if TRUE, will use strict type comparisons. So 9 will not work, you would have to pass '9', since the values are stored as strings. Returns the key of the first occurence of a match, NULL if the value is not found, or FALSE on error. make sure to use a strict comparison on the return value, since 0, NULL and FALSE are all possible return values and they will all evaluate to 0 if using loose integer comparisons.

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

Sidebar

Related Questions

I have a multi-dimensional array similar to the example below that I want to
Im looking for an example of multidimensional arrays. I have an array of thumbtails
In the multidimensional array below, I would like to merge arrays that have the
I have a multidimensional array with various config settings. Here's an example: $this->data =
Here's the problem. I ,for example,have a string 2500.Its converted from byte array into
I have a multidimensional array object, and in a loop I would like to
I have a multidimensional array that looks something like this: ourThing = array( 'id'
I have this example: var name; var id; var array = []; $.each(data, function(index,
I have product list ( 9 products in multidimensional array ), i want to
I have a string which represents a multidimensional array in the format: [[A, a],

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.