Thank you for taking some time to understand this problem. Let me set it up by defining the arrays involved and then the code I am trying to pull off.

I have this array >>
$query_array = array('keywords'=>5, 'title'=>4, 'summary'=>3, 'content'=>2);

I also have an array for each of the keys in the query array like this:

print_r($keywords_array) >>
Array ( [0] => Array ( [0] => 554 [1] => 551 [2] => 522 [3] => 502) [1] => Array ( [0] => 554 [1] => 520 [2] => 539))

print_r($title_array) >>
Array ( [0] => Array ( [0] => 502 ) [1] => Array ( [0] => 531 [1] => 528))

and two more arrays for the summary and content.

HERE'S WHAT I WANT TO DO...
I want to look at each key in the $query_array and use the key to help me loop through the other arrays listed above. Here's some code for example:

foreach ($query_array as $key => $value) {

$check_this_array = "$" . $key . "_array";

foreach ($check_this_array as $search_key => $search_id_array) {
// do stuff here
}

}

... in other words, i need the $check_this_array variable to actually become the $keywords_array or the $title_array, etc.

What am I missing here??

Thank you for any insights.

i am not really looking into the whole situation, just the code you provided.

change:

$check_this_array = "$" . $key . "_array";

to:

$check_this_array = ${$key.'_array'};

this might solve your problem

awesome, that worked. thank you for your time.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.