Created
October 17, 2012 20:49
-
-
Save loraxx753/3908087 to your computer and use it in GitHub Desktop.
PHP Practice 1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//Starting values (one way to do an array) | |
$peopleWhoHateChris = array('Jacob'); | |
//Adding to the array | |
$peopleWhoHateChris[] = 'John'; | |
$peopleWhoHateChris[] = 'Mike'; | |
//Another way to add | |
array_push($peopleWhoHateChris, 'Luke'); | |
//Step 1: print out the number of people who hate Chris by saying "X people think Chris is a fucking asshole." | |
//Step 2: Print out the 3rd person who hates Chris (should be Mike) | |
//Step 3: Remove the last person from the array, then print out each person in a list (with a loop) | |
//You're gonna have to look stuff up. | |
//Try googling "remove last item from array php" |
Almost right, you're unsetting "Mike" instead of the last item "Luke"
As for how to break it up, remember you can echo html right into this, so you could do print $name."
"; to add a line break between each or $name." "; for a space.
Damnit... lemme try that again
As for how to break it up, remember you can echo html right into this, so you could do print $name."<br/>"; to add a line break between each or $name." "; for a space.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Ok this should be all you wanted for real this time. Only problem is - how do I get a space between the unset and the foreach to print out the names. It all jams into a line and I cant figure out how to insert a nbsp or /n correctly.