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
Old 03-10-2010, 04:40 AM Simple array issue:
lynxus's Avatar
Awesomeo-Maximo

Posts: 1,618
Location: UK
Trades: 1
Hi Guys,

Ive got an array $usernames built from a Mysql select ( like below )

If i print_r i get: ( snippet )
PHP Code:
Array
(
    [
0] => cuyjtrfertge65gf
)
Array
(
    [
0] => asfdgwsdfgsfdgsdges
)
Array
(
    [
0] => asfasfsafasfsadf
)
Array
(
    [
0] => Mooooooooo
)


How can i foreach in this array?

Ive tried

foreach ($usernames as $key => $value){
echo 
$value;

But it only outputs one row.

Im assuming its because they key is 0 for each row.

This is how i populated the array.
$username = $row['username'];
$usernames = array($row['username']);
__________________

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

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


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

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



Last edited by chrishirst; 03-12-2010 at 08:51 AM..
lynxus is offline
Reply With Quote
View Public Profile Visit lynxus's homepage!
 
 
Register now for full access!
Old 03-10-2010, 04:57 AM Re: Simple array issue:
Experienced Talker

Posts: 41
Name: Adam B
Trades: 0
Code:
foreach ($usernames as $username)
{
    echo $username[0];
}
adam89 is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Simple array issue:
 

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.46664 seconds with 12 queries