Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!gegeweb.org!eternal-september.org!feeder.eternal-september.org!mx04.eternal-september.org!.POSTED!not-for-mail From: Arno Welzel Newsgroups: comp.lang.php Subject: Re: Fast/Easy way to extract a column from multi-dimensional array? Date: Sat, 28 Jan 2012 09:49:08 +0100 Organization: A noiseless patient Spider Lines: 41 Message-ID: <4F23B684.8030602@arnowelzel.de> References: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Injection-Info: mx04.eternal-september.org; posting-host="ATQwcILwL7NTAncYyFrc9Q"; logging-data="8704"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/8NLojTIqyl4jw6fVaW/T0ydN1XX6Gvm0=" User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:9.0) Gecko/20111222 Thunderbird/9.0.1 In-Reply-To: Cancel-Lock: sha1:s1D2vbY2NM/dOfGAuYEgoYL52QA= Xref: x330-a1.tempe.blueboxinc.net comp.lang.php:4652 John Drako, 2012-01-27 21:08: > 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. [...] > The site is very busy and CPU cycles count. I'm trying to avoid left > joining three gigantic tables. You always query *all* records with every request? And do you already use some kind of byte code cache (XCache etc.)? This also helps a lot to reduce the CPU load and the scripts can be executed 3-4 times faster, since the interpretation will only be done once and further requests get served by the cached byte code. -- Arno Welzel http://arnowelzel.de http://de-rec-fahrrad.de