Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
Old 01-22-2003, 03:49 PM   #1 (permalink)
Ilya020
Techno Rat
 
Ilya020's Avatar
 
Join Date: Jan 2003
Location: San Diego
Posts: 559
Ilya020 is on a distinguished road
Send a message via AIM to Ilya020
whats 0:

Hey guys,
for a website, I am making an array:
PHP Code:
<?php
$title
="Lists";
include(
"./header.php");
print 
"These are our lists;";
$lists= array(
    array(
"log"=>"blah""foo"),
    array(
"list"=>"fa""blah")
    );
foreach(
$lists as $val)
    {
    foreach(
$val as $key=>$fin_key)
        {
        print 
"<br />$key:<br />$fin_key<br />";
        }
    print 
"<br />";
    }


include(
"./footer.php");
?>
When I try this, I get this:



Lists

These are our lists;
log:
blah

0:
foo


list:
fa

0:
blah

I was wondering, why do I get "0:" in there?

Ilya

EDIT: I know that using the foreach is more C style than PHP...O well!
__________________
> SELECT * FROM users WHERE clue > 0
0 rows returned
Ilya020 is offline   Reply With Quote
Old 01-22-2003, 04:49 PM   #2 (permalink)
Ilya020
Techno Rat
 
Ilya020's Avatar
 
Join Date: Jan 2003
Location: San Diego
Posts: 559
Ilya020 is on a distinguished road
Send a message via AIM to Ilya020
what the question is also, Is how can I make

devel = foo and blah

Ilya
__________________
> SELECT * FROM users WHERE clue > 0
0 rows returned
Ilya020 is offline   Reply With Quote
Old 01-24-2003, 04:03 PM   #3 (permalink)
Ilya020
Techno Rat
 
Ilya020's Avatar
 
Join Date: Jan 2003
Location: San Diego
Posts: 559
Ilya020 is on a distinguished road
Send a message via AIM to Ilya020
nm, I got the answer somewhere else. Ill post it later, lazy now

Ilya
__________________
> SELECT * FROM users WHERE clue > 0
0 rows returned
Ilya020 is offline   Reply With Quote
Old 01-25-2003, 07:45 AM   #4 (permalink)
redhead
Newbie
 
redhead's Avatar
 
Join Date: Jun 2002
Location: Denmark
Posts: 1,694
redhead is on a distinguished road
Re: whats 0:

Quote:
Originally posted by ilya020
When I try this, I get this:

Lists

These are our lists;
log:
blah

0:
foo


list:
fa

0:
blah

I was wondering, why do I get "0:" in there?
The code does what you tell it to do, displayes every item in your list, you have a first item, with identifyer "log->blah" that holds value "foo" in the foreach it just tels you that the identifyer log is reffering to the blah, and that the first item (0) is holding the value foo.

Quote:
Originally posted by ilya020

EDIT: I know that using the foreach is more C style than PHP...O well!
It is _not_ C style, it is a derived feature from the C shell where foreach is buildin as a special command. php programmers just thought it would be a useful command in the php language aswell.
If anything I would say foreach orriginates from perl (http://www-106.ibm.com/developerwork...ry/l-p560.html)
__________________
Don't worry Ma'am, We're university students, We know what We're doing.
-----
If you pull the pin, Mr.Grenade would no longer be your friend.
-----
01000111 01101111 00100000 01000011 00100000 00100001
redhead is offline   Reply With Quote
Old 01-25-2003, 12:06 PM   #5 (permalink)
Ilya020
Techno Rat
 
Ilya020's Avatar
 
Join Date: Jan 2003
Location: San Diego
Posts: 559
Ilya020 is on a distinguished road
Send a message via AIM to Ilya020
Re: Re: whats 0:

Quote:
Originally posted by redhead


The code does what you tell it to do, displayes every item in your list, you have a first item, with identifyer "log->blah" that holds value "foo" in the foreach it just tels you that the identifyer log is reffering to the blah, and that the first item (0) is holding the value foo.


It is _not_ C style, it is a derived feature from the C shell where foreach is buildin as a special command. php programmers just thought it would be a useful command in the php language aswell.
If anything I would say foreach orriginates from perl (http://www-106.ibm.com/developerwork...ry/l-p560.html)
0





Ilya
__________________
> SELECT * FROM users WHERE clue > 0
0 rows returned
Ilya020 is offline   Reply With Quote
Old 01-25-2003, 01:45 PM   #6 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,446
sde is on a distinguished road
ah, i have been missing redhead's wisdom around here.
sde is offline   Reply With Quote
Old 01-25-2003, 02:38 PM   #7 (permalink)
Ilya020
Techno Rat
 
Ilya020's Avatar
 
Join Date: Jan 2003
Location: San Diego
Posts: 559
Ilya020 is on a distinguished road
Send a message via AIM to Ilya020
redheads are always lucky and smart....Vlad is just an exception. :p

Ilya
__________________
> SELECT * FROM users WHERE clue > 0
0 rows returned
Ilya020 is offline   Reply With Quote
Old 01-25-2003, 03:02 PM   #8 (permalink)
anon
Guest
 
Posts: n/a
Quote:
Originally posted by ilya020
redheads are always lucky and smart....Vlad is just an exception. :p

Ilya
DUDE! I don't have red hair!

/me runs away and shaves head
  Reply With Quote
Old 01-25-2003, 03:29 PM   #9 (permalink)
Ilya020
Techno Rat
 
Ilya020's Avatar
 
Join Date: Jan 2003
Location: San Diego
Posts: 559
Ilya020 is on a distinguished road
Send a message via AIM to Ilya020
/me says "skinhead";:p


ilya
__________________
> SELECT * FROM users WHERE clue > 0
0 rows returned
Ilya020 is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

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 On
Pingbacks are On
Refbacks are On



All times are GMT -8. The time now is 05:19 AM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting