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

  • Home
  • SEARCH
  • 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 6685631
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T05:04:45+00:00 2026-05-26T05:04:45+00:00

I have a multi-dimensional array of databases, which was generated from my server: //

  • 0

I have a multi-dimensional array of databases, which was generated from my server:

// place db tables into array
$da_db = array(
'test' => array(
    // test.users
    'users' => array('fname','lname','info'),
    // test.webref_rss_details
    'webref_rss_details' => array('id','title','link','description','language','image_title','image_link','item_desc','image_width','image_height','image_url','man_Edit','webmaster','copyright','pubDate','lastBuild','category','generator','docs','cloud','ttl','rating','textInput','skipHours','skipDays'),
    // test.webref_rss_items
    'webref_rss_items' => array('id','title','description','link','guid','pubDate','author','category','comments','enclosure','source','chan_id')
),
'db_danaldo' => array(
    //code here
),
'frontacc' => array(
    //code here
)

[array][db][table][field]

As you can see, the database currently populated refers to an RSS project I am working on – one table for Channels, another for Items in that channel, at the moment that is another issue (‘Users’ table for now is not important)..

what I want to do is to return the array/sub-array names and convert each into variables for use as part of a string in an SQL Query, also need an alias for the tables I need to connect with:

(e.g. SELECT * FROM 'webref_rss_items' WHERE 'chan_id' = 'test.webref_rss_details.id')

where ‘webref_rss_items’ is a variable, ‘chan_id’ is a variable and ‘test.webref_rss_details.id’ are 3 variables in a concatenated string, although I’ve heard the concatenation in an SQL Query is not good practice, security-wise.. the strange thing is of all of those values, all I can retreive is the deepest level, ‘id’:

echo "{$da_db['test']['webref_rss_details'][0]}"

but get ‘Array’ returned or the last value of an array when I try to access the names!!

The reason for this is that the PHP file with the query will be within the ‘public’ part of the server and would like to have use variables with have no connotation to the original name(s), also it seems more convenient as the variables can be interchangable and I won’t be using the same path all the time.

EDIT: My idea is to get key names from ['db'] to ['field']. The closest I have reached is to iterate keys and array_fill in a foreach loop, use range() inside another foreach, array_combine both then var_dump combined array like so:

foreach($da_db['test'] as $key1 => $val) { //put key-names into array1 to use as values
$a = array();
$a = array_fill(0, 1, $key1);
print($key1.'<br />');
}   

foreach (range(0, 2) as $number) {         //array for numbers to use as keys
$b = array();
$b = array_fill(0, 1, $number);
    echo $number.'<br />';
}

$c = array_combine($b, $a);                //combine both for new array
print_r($c.'<br />');

I could the use array_slice to get the name I want! (long winded?)
The problem is that the result of this only shows the last key => value; depending on command(print_r, print, echo), it shows:

[2] => webref_rss_items 

OR
Array.

I hope that is enough info for now.

I’ve seen similar questions on here, but normally apply to one value, or one level of an array, but if you have seen this question before please advise and point me in right direction.

  • 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-26T05:04:46+00:00Added an answer on May 26, 2026 at 5:04 am

    Your two top level arrays (db name and table name) are “named-key” arrays. The field level array (value of table name array) is an “integer key” array. PHP automatically adds numerical indexes for arrays that are defined with values only. For “named-key” arrays, you can only access their values by using the key name you defined.

    For example:

    $array1 = array('zero', 'one', 'two');
    echo $array1[2]; // two
    
    $array2 = array('zero' => 'this is zero', 'one' => 'this is one');
    echo $array2['zero']; // this is zero
    echo $array2[0]; // undefined
    

    PHP provides a function called array_keys() that will return you an integer index array with all the key names. So you access your table array using an integer value, you can do this.

    $da_db_test_keys = array_keys($da_db['test']);
    echo $da_db_test_keys[1];
    

    Maybe this will help you a little bit. I wasn’t 100% on how you planned on accessing the values in your arrays, so if you have any more questions please try to clarify that part.

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

Sidebar

Related Questions

Okay, I have a multi-dimensional array which is statically-allocated. I'd very much like to
I have a multi-dimensional array generated in PHP: array( 'Requirements' => array( 'export_requirements' =>
I have a multi-dimensional array that I am trying to feed into difflib.get_close_matches() .
I have a multi-dimensional array with 4 entries in each value - (1st name,
I have a multi-dimensional array right now that looks like this: function art_appreciation_feeds() {
I have a multi dimensional array called soldier: Array ( [0] => Array (
I have a multi-dimensional array similar to the example below that I want to
I have a multi-dimensional array that looks like this: The base array is indexed
Suppose I have a multi-dimensional array of the form: array ( array('Set_ID' => 1,
So I have a multi-dimensional array looks like this. $config = array( First Name

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.