Fast/Easy way to extract a column from multi-dimensional array?
- From: John Drako <jbravo556@xxxxxxxxxxxxxxxxxxxx>
- Date: Fri, 27 Jan 2012 15:08:01 -0500
I'm looking for a way to get all the values from the column of a two
dimensional array.
For example, I have a query on a mysql database that returns 10 rows
from the database, I would like to quickly (read low cpu load) extract
all the IDs from all the rows returned to reuse in another query.
So let's say I use:
$arr = mysqli_fetch_all($result, MYSQLI_ASSOC);
and $arr looks like:
RecordID, name, last name, title
RecordID, name, last name, title
RecordID, name, last name, title
RecordID, name, last name, title
RecordID, name, last name, title
RecordID, name, last name, title
etc...
I need to get all the 'RecordID' from the results to reuse in other
queries.
Is there a built in PHP function (compiled code) to accomplish this?
I've read the definitions of all the functions related to arrays and if
it exists, I didn't find it.
The site is very busy and CPU cycles count. I'm trying to avoid left
joining three gigantic tables.
.
- Follow-Ups:
- Re: Fast/Easy way to extract a column from multi-dimensional array?
- From: Arno Welzel
- Re: Fast/Easy way to extract a column from multi-dimensional array?
- From: Jeff North
- Re: Fast/Easy way to extract a column from multi-dimensional array?
- From: Thomas Mlynarczyk
- Re: Fast/Easy way to extract a column from multi-dimensional array?
- From: J.O. Aho
- Re: Fast/Easy way to extract a column from multi-dimensional array?
- Prev by Date: Re: redirect stdout and stderr to PHP variables?
- Next by Date: Re: Fast/Easy way to extract a column from multi-dimensional array?
- Previous by thread: Product page getting Redirect back to Home page - Please Fix
- Next by thread: Re: Fast/Easy way to extract a column from multi-dimensional array?
- Index(es):
Relevant Pages
|