unknowncheats uc-forum.com ucdownloads ucdownloads.com

Go Back   UC-Tutorials - Multiplayer Game Hacking and Cheat Tutorials > Web / Scripting > PHP

- Sponsored Advertisement -
http://www.myfpscheats.com/


Reply
 
Thread Tools Display Modes
  #1  
Old 12-23-2006, 07:53 AM
zero_tolerance zero_tolerance is offline
Senior Member
 
Join Date: Dec 2006
Posts: 289
Default NeMSeR's Tutorials - PHP Arrays

By NeMSeR

NeMSeR's Arrays PHP Tutorial

This will basically explain how to handle and set arrays.

First of all lets assume a previous page has been made which lets users enter 3 fields of text containing their favourite movies. This tut will be demonstrated by using the action="example_page.php" commands in the form.

Now first of all we want to set an array. To do this we use this command:

PHP Code:
$movies = array(); 
Assuming that the 3 textfields on the previous page's form are called movie1, movie2 and movie3 we will use this to input that information into the array.

PHP Code:
$movies = array($_POST['movie1'], $_POST['movie2'], $_POST['movie3']); 
Once we have done that we can call the array by using this.

PHP Code:
echo "The movies are $movies"
Now, your probably wondering how we seperate each string inside the array. Well that is done by using foreach. This is an example, this code will print each movie on a different line.

PHP Code:
foreach ($movies as $value) {
echo 
$value "<br>";

Here is it all put together, i have also added a little something else to put them in alphabetical order.

PHP Code:
    //first of all we shall set the array 
$movies = array($_POST['movie1'], $_POST['movie2'], $_POST['movie3']); 

//next we will put them in alphabetical order 
asort($movies); 

//now we will split the array and show the results 
foreach ($movies as $value) { 
echo 
$value "<br>"

That's it for arrays, if you want anything simplified then reply here.
Reply With Quote
Reply

  • Submit Thread to Digg
  • Submit Thread to del.icio.us
  • Submit Thread to StumbleUpon
  • Submit Thread to Google
  • Submit Thread to Facebook
  • Submit Thread to My Yahoo!
  • Submit Thread to MySpace
  • Submit Thread to Twitter
  • Submit Thread to Reddit

Tags
arrays, nemser, php, tutorials

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



All times are GMT. The time now is 06:41 AM.