Toon-Workshop Terms Of Service Agreement Anything to do with accounts created on this site is our business. We will respect your privacy and only monitor any activity going on with your account if we feel there is a valid reason. Some reasons may include: Threats Racism Spam False Advertising Advertising Witout Permission or Abusing Account Priveleges Any content submitted to this site must be made or created by the user who submits it. We are not claiming ownership over your work. Whats yours is yours! If you are found to be submitting others work, the content will be deleted, your account will be suspended, alongside your ip address. Racist, malicious, or inapropriate material will be dealt with in the same manor. Any crimes found to be committed on this site will be dealt with by law. We do not play around when it comes to this community being a civil and peacfull place. Only one account is permitted per person. If you are found to own multiple accounts you will be banned from the site. The Terms Of Service Agreement Can Be Updated at Any Point In Time. Rules may vary and change as time passes by.

 
                 
Toon-Workshop
                 
 
 
 
   
 
 
   
 
Forum Topic: php array

Home > Forums > Tutorials > php array (91 views - 3 replies)

   
1

Author   Topics:
bbadmin


Posts: 6

Exp: 5
Muny: 0
Posted At: 07/23/08, 2:55 pm
[PM | Email | Profile] [user]

What we need to do is start off with creating our array.

<?php

$array = array(

);

?>

Now lets add some details to our array.

<?php

$array = array(

\'red\' => \'Apple\' ,
\'green\' => \'Grapes\' ,
\'blue\' => \'Berries\'

);

?>

Now if we want to list BOTH color AND fruit, we will echo the color AND fruit. For now lets replace the color wtih the fruit, then we will display both.

<?php

$array = array(

\'red\' => \'Apple\' ,
\'green\' => \'Grapes\' ,
\'blue\' => \'Berries\'

);

foreach ($array as $color => $fruit) { /* will search our array & switch the fruit with the color */

echo \"$fruit<br>\\n\";

/* will output the fruits listed in our array! */

}

?>

Now lets display our colors and fruits. very simple just adding an extract variable to our loop.

<?php

$array = array(

\'red\' => \'Apple\' ,
\'green\' => \'Grape\' ,
\'blue\' => \'Berries\'

);

foreach ($array as $color => $fruit) {

echo \"$color = $fruit<br>\\n\";

}

?>

simple! Enjoy



bbadmin


Posts: 6

Exp: 5
Muny: 0
Posted At: 07/23/08, 2:57 pm
[PM | Email | Profile] [ user ]

It added slashes when I edited the post. Sorry all !



Fallin_Again


Posts: 318

Exp: 90
Muny: 0
Posted At: 07/25/08, 1:30 pm
[PM | Email | Profile] [ admin ]

thats another bug ill have to fix. but thats a great tutorial. i sent you a pm.


IM THE DAMN ADMIN! DONT BE STUPID............STUPID!
Rule #1: Im always right.
Rule #2: If you have any problems refer to rule #1

bbadmin


Posts: 6

Exp: 5
Muny: 0
Posted At: 07/26/08, 12:03 am
[PM | Email | Profile] [ user ]

In the edit function, add stripslashes(); to the code.



Toon-Workshop  

1

Home | Toons | Music | Games | Tutorials | Forums | Submit | FAQ | Contact © 2006-2008 Toon-Workshop.net