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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T05:08:11+00:00 2026-05-28T05:08:11+00:00

I need to produce an array that is formatted as follows: Array( Array([100000116287110]=> Array([name]

  • 0

I need to produce an array that is formatted as follows:

Array(  
Array([100000116287110]=>  
Array([name] => Bryce [image] => abcd.png))  
Array([100003019827186]=>  
Array([name] => Ross [image] => defg.png))  
)  

The data to produce the array comes from 2 different sources and is fed to a function.

The function call is lookupUserData($a, array(“name”, “image”)) //this has been set up so other details from the user table can be called simply by adding the field name in the array.
$a is formated as $a = “100000116287110,100003019827186”

The current code I am using for the function is as follows:

function lookupUserData($f,$u)
{
$f = explode(",",$f); //user id from string – converts string to array ([0] =>100000116287110 [1] =>100003019827186)
$u = implode(",",$u); //fields to extract – converts array(“name”,”image”) to name,image
$r=array(); //define results array`
$nr = count($f); //count number of ids to process
for($i=0; $i<$nr; $i++) { //process each id in $f array
$r[]=$f[$i];
$res = mysql_query("SELECT {$u} FROM users where id ={$f[$i]}"); //query user table
$val= mysql_fetch_assoc($res); //return requested fields ($u) from user table
array_push($r, $val); //add values to array $r
}
print_r ($r); //check array output – testing only
return $r; //return array for processing
}

This however returns the result as follows:

Array(  
Array([0]=>[100000116287110]  
Array([name] => Bryce [image] => abcd.png))  
Array([1]=>[100003019827186]  
Array([name] => Ross [image] => defg.png))  
)

I know I have missed something simple but just cannot seem to get this right!

  • 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-28T05:08:12+00:00Added an answer on May 28, 2026 at 5:08 am

    Something like this:

    
    $r= array();
    for($i=0; $i<$nr; $i++) { //process each id in $f array
    
     $res = mysql_query("SELECT {$u} FROM users where id ={$f[$i]}"); //query user table
     $val= mysql_fetch_assoc($res); //return requested fields ($u) from user table
     $r[$f[$i]] = $val;
    }
    
    
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm writing a small .NET application that can produce SWF files, and I need
I need to write a code snippet that would compare multiple arrays and produce
I need to merge consecutive repeating elements in an array, such that [1, 2,
I need to create routes that include a colon to produce URLs like http://app.com/prjct:a9b5c
I need to produce a calculation trace file containing tabular data showing intermediate results.
I need to produce a SQL report showing the number of times a particular
I need to produce somewhat complicated PDFs from a Rails app - tables with
I need to produce an id surrounded by braces ( for example {1234} ).
I have need to produce LINE, BAR, and PIE charts in Rails. I have
I have two unsorted lists and I need to produce another list which is

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.