NamePros
Welcome, Guest! Ready to make a name for yourself in the domain business? We welcome both the hobbyist and professional domainer to join the discussion as part of the NamePros community.

Click here to create your profile to start earning reputation for posting, and trader ratings for buying & selling in our free e-marketplace. Build your trader rating with each successful sale. Our system has tracked over 100,000 sales and counting!
FAQ & TOS Register Search Today's Posts Mark Forums Read

Go Back   NamePros.com > Website Development Discussion Forums > Programming > CODE
Reload this Page Introduction to PHP Arrays

CODE This forum is for posting code snippets and example scripts that aren't quite tutorials, but could be useful for others. You may post code snippets and/or completed scripts that you've written and want to share here.

Advanced Search


Closed Thread
 
LinkBack Thread Tools
Old 07-11-2008, 05:03 PM THREAD STARTER               #1 (permalink)
Account Closed
Join Date: Jun 2008
Posts: 156
itnashvillecom has a spectacular aura aboutitnashvillecom has a spectacular aura about
 



Thumbs up Introduction to PHP Arrays


Let's say that you want to store numerous values within one variable. It may sound complex for some of you, but to those of us that use arrays daily, they are a God send. They help us to unclutter and organize our code and speed up development.

How to create an array:

PHP Code:
$cars = array(=> "Chevy"2=> "Honda"3=> "Mitsubishi"); 

????: NamePros.com http://www.namepros.com/code/491756-introduction-to-php-arrays.html
Now you can use this array.

PHP Code:
$cars = array(=> "Chevy"2=> "Honda"3=> "Mitsubishi");
????: NamePros.com http://www.namepros.com/showthread.php?t=491756
if (
$_POST['favorite'] == 2) {
     
$favorite_car $cars[2];
     echo 
'Your favorite make of car is '.$favorite_car;

This will print:

Quote:
Your favorite make of car is Honda
*Note: Do not use quotes in the array when using the numeric key. $cars['2'] is bad. However, you can use $cars['Honda'].
itnashvillecom is offline  
Old 07-11-2008, 05:14 PM   #2 (permalink)
NamePros Legend
 
weblord's Avatar
Join Date: Dec 2005
Location: Philippines - www.Nabaza.com
Posts: 19,785
weblord Has achieved greatnessweblord Has achieved greatnessweblord Has achieved greatnessweblord Has achieved greatnessweblord Has achieved greatnessweblord Has achieved greatnessweblord Has achieved greatnessweblord Has achieved greatnessweblord Has achieved greatnessweblord Has achieved greatnessweblord Has achieved greatness
 


Autism Protect Our Planet
some good books as well on amazon

http://www.amazon.com/s/?url=search-...rays&x=12&y=21
__________________
Nabaza.com - Amaia
Last edited by peter@flexiwebhost; 07-12-2008 at 04:09 AM. Reason: No Affiliate Links
weblord is offline  
Old 07-11-2008, 05:18 PM THREAD STARTER               #3 (permalink)
Account Closed
Join Date: Jun 2008
Posts: 156
itnashvillecom has a spectacular aura aboutitnashvillecom has a spectacular aura about
 



Yes indeed. I am partial to recommending PHP5 for Dummies. It is very thorough and within 30 days you can be coding excellent scripts.
itnashvillecom is offline  
Old 07-11-2008, 05:19 PM   #4 (permalink)
NamePros Legend
 
weblord's Avatar
Join Date: Dec 2005
Location: Philippines - www.Nabaza.com
Posts: 19,785
weblord Has achieved greatnessweblord Has achieved greatnessweblord Has achieved greatnessweblord Has achieved greatnessweblord Has achieved greatnessweblord Has achieved greatnessweblord Has achieved greatnessweblord Has achieved greatnessweblord Has achieved greatnessweblord Has achieved greatnessweblord Has achieved greatness
 


Autism Protect Our Planet
yeah better catching the latest
Originally Posted by itnashvillecom
Yes indeed. I am partial to recommending PHP5 for Dummies. It is very thorough and within 30 days you can be coding excellent scripts.
__________________
Nabaza.com - Amaia
weblord is offline  
Old 07-11-2008, 06:33 PM   #5 (permalink)
New Member
Join Date: Jun 2008
Posts: 18
humair4 is an unknown quantity at this point
 



I prefer php.net or How to Do Everything with PHP and MySQL and if your looking for something for absolute beginners you could Php Phrasebook Essential Code and you could get some of these ebooks at http://betah.co.il/ you could find more if you search here. I hope you find this helpful
humair4 is offline  
Old 07-11-2008, 06:48 PM   #6 (permalink)
NamePros Member
Join Date: Sep 2006
Posts: 99
Bruce_KD will become famous soon enoughBruce_KD will become famous soon enough
 



Honestly, my belief is that if you really need to buy books to learn a programming language, you're probably not cut out to be a web designer.
Books are great, they spoon feed you everything piece by piece.

However, in my opinion, there is So much information online that anyone who really has the passion to learn would just use php.net, w3schools, etc.
And if you don't have the passion, go be a used car salesman or something.


Bruce
Bruce_KD is offline  
Old 07-11-2008, 06:51 PM   #7 (permalink)
NamePros Legend
 
weblord's Avatar
Join Date: Dec 2005
Location: Philippines - www.Nabaza.com
Posts: 19,785
weblord Has achieved greatnessweblord Has achieved greatnessweblord Has achieved greatnessweblord Has achieved greatnessweblord Has achieved greatnessweblord Has achieved greatnessweblord Has achieved greatnessweblord Has achieved greatnessweblord Has achieved greatnessweblord Has achieved greatnessweblord Has achieved greatness
 


Autism Protect Our Planet
yes i know. get all your hands on everything you can get to learn.
can't do away with books.
btw programming is entirely different from web design.
my books are my reference, they are very handy to me while the internet is down esp. in our country. every 4 hours down

Originally Posted by Bruce_KD
Honestly, my belief is that if you really need to buy books to learn a programming language, you're probably not cut out to be a web designer.
Books are great, they spoon feed you everything piece by piece.

However, in my opinion, there is So much information online that anyone who really has the passion to learn would just use php.net, w3schools, etc.
????: NamePros.com http://www.namepros.com/showthread.php?t=491756
And if you don't have the passion, go be a used car salesman or something.


Bruce
__________________
Nabaza.com - Amaia
weblord is offline  
Old 07-11-2008, 07:31 PM   #8 (permalink)
New Member
Join Date: Jun 2008
Posts: 18
humair4 is an unknown quantity at this point
 



Originally Posted by Bruce_KD
Honestly, my belief is that if you really need to buy books to learn a programming language, you're probably not cut out to be a web designer.
Books are great, they spoon feed you everything piece by piece.

However, in my opinion, there is So much information online that anyone who really has the passion to learn would just use php.net, w3schools, etc.
And if you don't have the passion, go be a used car salesman or something.


Bruce
I was talking about a programmer/developer, and if you think people learning from books aren't cut out to be web designers well i don't agree most people learn from books, and even most of the information on the internet related to web designing is from books.
humair4 is offline  
Old 07-11-2008, 07:44 PM THREAD STARTER               #9 (permalink)
Account Closed
Join Date: Jun 2008
Posts: 156
itnashvillecom has a spectacular aura aboutitnashvillecom has a spectacular aura about
 




Learning on the web, people tend to have holes in their education. If you were correct, then we would not have evolved past the point seeing the world as flat. The most efficient manner is to learn thoroughly the basics, and then work up by experimentation and further study.

Quote:
And if you don't have the passion, go be a used car salesman or something.
I would hire a person with an education via theory and practice over just practice any day. I want a person that truly understands WHY to do something, not just that it can be done.
Last edited by itnashvillecom; 07-11-2008 at 10:27 PM.
itnashvillecom is offline  
Old 07-11-2008, 10:15 PM   #10 (permalink)
New Member
Join Date: Jun 2008
Posts: 18
humair4 is an unknown quantity at this point
 



Originally Posted by itnashvillecom
Learning on the web, people tend to have holes in their education. If you were correct, then we would not have evolved past the point seeing the world as flat. The most efficient manner is to learn thoroughly the basics, and then work up by experimentation and further study.
true
humair4 is offline  
Old 09-08-2008, 08:10 PM   #11 (permalink)
Senior Member
Join Date: Apr 2005
Location: Joliet, Illinois
Posts: 1,177
RageD is a splendid one to beholdRageD is a splendid one to beholdRageD is a splendid one to beholdRageD is a splendid one to beholdRageD is a splendid one to beholdRageD is a splendid one to beholdRageD is a splendid one to beholdRageD is a splendid one to behold
 


Child Abuse
Originally Posted by itnashvillecom
*Note: Do not use quotes in the array when using the numeric key. $cars['2'] is bad. However, you can use $cars['Honda'].
Don't forget to teach them how to use the numbers

$cars[2] will output the information in 2 in the array.
????: NamePros.com http://www.namepros.com/showthread.php?t=491756

-RageD
RageD is offline  
Closed Thread


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools


Liquid Web Smart Servers  
All times are GMT -7. The time now is 04:08 AM.

Managed Web Hosting by Liquid Web
Domain name forum recommended by Domaining.com Powered by: vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.6.0 Ad Management plugin by RedTyger