Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Using LIST to extract array info
Old 09-14-2011, 03:54 AM Using LIST to extract array info
numbenator's Avatar
Webmaster Talker

Posts: 523
Location: London
Trades: 0
Hi All

I have an array in the below structure.
How do i use list to extract just the name

Code:
Array ( [data] => Array ( [0] => Array ( [name] => Sebastian Penalosa [id] => 28100059 ) [1] => Array ( [name] => Oogie Sapu [id] => 72611865 ) [2] => Array ( [name] => Charlie Vance [id] => 199705644 ) [3] => Array ( [name] => Claire Phillips [id] => 508032563 ) [4] => Array ( [name] => Louise Davis [id] => 508711924 ) [5] => Array ( [name] => Carl Stephenson [id] => 512439546 ) [6] => Array ( [name] => Gav Smith [id] => 516476214 ) [7] => Array ( [name] => Prab S Chandhok [id] => 517365446 ) [8] => Array ( [name] => David Bishop [id] => 517641342 ) [9] => Array ( [name] => Mark 'Ginge' Jones [id] => 519908656 )
cheers

Steve
__________________

Please login or register to view this content. Registration is FREE
numbenator is offline
Reply With Quote
View Public Profile Visit numbenator's homepage!
 
 
Register now for full access!
Old 09-14-2011, 05:02 AM Re: Using LIST to extract array info
vectorialpx's Avatar
Extreme Talker

Posts: 249
Name: octavian
Location: Bucharest
Trades: 0
let's say you have

$main = array ( [data] => Array (
[0] => Array ( [name] => Sebastian Penalosa [id] => 28100059 )
[1] => Array ( [name] => Oogie Sapu [id] => 72611865 )
[2] => Array ( [name] => Charlie Vance [id] => 199705644 )
...
)
# not using list
$finalArray = array();
foreach($main['data'] as $_tempValues) {
$finalArray[] = $_tempValues['name']
}
__________________
you can
Please login or register to view this content. Registration is FREE
vectorialpx is offline
Reply With Quote
View Public Profile Visit vectorialpx's homepage!
 
Old 09-14-2011, 05:13 AM Re: Using LIST to extract array info
numbenator's Avatar
Webmaster Talker

Posts: 523
Location: London
Trades: 0
Thanks very much.
Can it not be done with a list then?
__________________

Please login or register to view this content. Registration is FREE
numbenator is offline
Reply With Quote
View Public Profile Visit numbenator's homepage!
 
Old 09-14-2011, 05:16 AM Re: Using LIST to extract array info
Super Spam Talker

Posts: 879
Name: Paul W
Trades: 0
Quote:
Originally Posted by numbenator View Post
Thanks very much.
Can it not be done with a list then?
No: list is just a construct to assign a list of variables. It "works" okay in the way you want it on a one dimensional array, not on other arrays.
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE


*** New:
Please login or register to view this content. Registration is FREE
PaulW is offline
Reply With Quote
View Public Profile
 
Old 09-14-2011, 05:23 AM Re: Using LIST to extract array info
numbenator's Avatar
Webmaster Talker

Posts: 523
Location: London
Trades: 0
nice one.
Thanks very much for you input.
__________________

Please login or register to view this content. Registration is FREE
numbenator is offline
Reply With Quote
View Public Profile Visit numbenator's homepage!
 
Reply     « Reply to Using LIST to extract array info
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.59936 seconds with 12 queries