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-10-2003, 04:35 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
wierd output

Hey guys,

In PHP I made an array as follows

PHP Code:
<?php
$crew 
= array (
    
"Name"  => array ("Ilya"),
    
"age" => array (13),
    
"location"   => array ("San Diego, Ca")
);
 echo 
"$crew";
?>
When I test it, all that happens is it says "Array"
(without the quotes)

I was wondering why it does this and what is wrong with my array?

Thanks,

Ilya


P.S. Dont laugh at my code, i know it probably really buggy.

BTW. I googled on this for about 1 hour and even used the example from php.net and got the same results.
__________________
> SELECT * FROM users WHERE clue > 0
0 rows returned
Ilya020 is offline   Reply With Quote
Old 01-10-2003, 06:46 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
any ideas?

This is really bothering me, I want it to work!

Ilya
__________________
> SELECT * FROM users WHERE clue > 0
0 rows returned
Ilya020 is offline   Reply With Quote
Old 01-10-2003, 07:01 PM   #3 (permalink)
DesertWolf
Non-profit Techie
 
DesertWolf's Avatar
 
Join Date: Dec 2002
Location: Mesa AZ
Posts: 76
DesertWolf is on a distinguished road
Send a message via AIM to DesertWolf
Well to start with your array structure is wrong and when you echo output you are getting "array" because you are not calling out the elements of the array.
Try this:

<?php
$crew*=*array(
****"Name"*=>"Ilya",
****"age"=>13,
****"location"=>"San Diego, Ca"
);
for ($n=0;$n<count($crew); $n++) {
$Line = each ($crew);
print ("$Line[key] : $Line[value].<P.\n");
}
?>

I'm not sure if that is perfect I haven't messed with PHP very much, but if you plan on printing out more that one persons info you should look at using an array for names, ages and locations.
DesertWolf is offline   Reply With Quote
Old 01-10-2003, 07:23 PM   #4 (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
thanks, I will try it as soon as I get a chance.
__________________
> SELECT * FROM users WHERE clue > 0
0 rows returned
Ilya020 is offline   Reply With Quote
Old 01-18-2003, 11:23 AM   #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
I just figured out that I am an idiot! I needed to do a foreach statement and I am soooo dumb!


Ilya
__________________
> SELECT * FROM users WHERE clue > 0
0 rows returned
Ilya020 is offline   Reply With Quote
Old 01-18-2003, 11:24 AM   #6 (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
Quote:
Originally posted by DesertWolf
Well to start with your array structure is wrong and when you echo output you are getting "array" because you are not calling out the elements of the array.
Try this:

<?php
$crew = array(
"Name" =>"Ilya",
"age"=>13,
"location"=>"San Diego, Ca"
);
for ($n=0;$n<count($crew); $n++) {
$Line = each ($crew);
print ("$Line[key] : $Line[value].<P.\n");
}
?>

I'm not sure if that is perfect I haven't messed with PHP very much, but if you plan on printing out more that one persons info you should look at using an array for names, ages and locations.
BTW, you dont need quotes around Name and Age and location, you only need quotes for two or more words...


Ilya
__________________
> SELECT * FROM users WHERE clue > 0
0 rows returned
Ilya020 is offline   Reply With Quote
Old 01-18-2003, 02:17 PM   #7 (permalink)
DesertWolf
Non-profit Techie
 
DesertWolf's Avatar
 
Join Date: Dec 2002
Location: Mesa AZ
Posts: 76
DesertWolf is on a distinguished road
Send a message via AIM to DesertWolf
You need the quotes if the value is a string......
DesertWolf is offline   Reply With Quote
Old 01-18-2003, 02:21 PM   #8 (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
w00t? It works without them...I think...


Ilya
__________________
> SELECT * FROM users WHERE clue > 0
0 rows returned
Ilya020 is offline   Reply With Quote
Old 01-18-2003, 02:27 PM   #9 (permalink)
DesertWolf
Non-profit Techie
 
DesertWolf's Avatar
 
Join Date: Dec 2002
Location: Mesa AZ
Posts: 76
DesertWolf is on a distinguished road
Send a message via AIM to DesertWolf
Well without seeing your code it is hard to see what it is or would do.
DesertWolf is offline   Reply With Quote
Old 01-18-2003, 06:13 PM   #10 (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
I just realized you all now know my age and Vlads age!


jpjp...

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Adjust physical output size dynamically metazai PHP 8 08-24-2004 10:15 AM
hashing help saiz66 Standard C, C++ 2 06-28-2004 01:39 AM
Compiler Error saiz66 Standard C, C++ 9 06-10-2004 06:44 PM
flush output to browser sde Java 2 05-06-2004 04:08 PM
using exec() and getting output anon PHP 50 01-21-2003 03:58 PM


All times are GMT -8. The time now is 10:42 PM.


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