This site may be ugly as hell, but the code isn't.

Part 1 - Refresher

Here's what you should have covered in the far-better Code Acadamy lessons. I'll use these liberally from here on out so be sure you know what these all are. ALSO I've spent 0 time making the output "look good". This is essentially outputting HTML that you would normally only see at Geocities, since the focus here is on PHP code, and not HTML or CSS.

Click that shitty "SHOW SOURCE!" button at the bottom of every page to look at the entire lesson's code in full. I've forced you to look at this page's source already.


You should be familiar with the following by now:

-- If-Else loops

-- Switch-cases. (need to review?)

-- Arrays, accessing them with purdy [], accessing them with evil {} , and modifying their elements, and deleting items

- For loops- For loops- For loops- For loops

- Iterating through an array using foreach

-- While loops-- While loops-- While loops-- While loops-- While loops-- While loops

- Do-While loops

And have now dipped your toes in the steaming cesspool of randomly named and formatted built-in PHP functions:

- print (usually just use echo instead...)
- STRTOUPPER (AKA STOP YELLING AT ME)
- strtolower (thank you)
- substr (to make this sentence end abrup
- strpos (to find the index a nested string starts)
- round (to make 3.14159265359 3.14)
- floor (to make 3.14159265359 3)
- celi (to make 3.14159265359 4)
- rand (to make random numbers like 63055052)
- sort (alphabetically array make of ordered this to words)

AND (some of) THE REST:
count(), array_push(), array_shift(), rsort(), ksort(), usort()... blah blah blah (no one really memorizes these extensively for a long time... use google A LOT to find what you need)


BUT WAIT THERE'S MORE!!!



Up next, we'll cover creating your own functions. Click this hideous button to continue:

SOURCE CODE:

<i>This site may be ugly as hell, but the code isn't.</i>

<h1>Part 1 - Refresher</h1>
<p>Here's what you should have covered in the far-better Code Acadamy lessons. I'll use these liberally from here on out so be sure you know what these all are. ALSO I've spent 0 time making the output "look good". This is essentially outputting HTML that you would normally only see at Geocities, since the focus here is on PHP code, and not HTML or CSS.</p>

<p><b>Click that shitty "SHOW SOURCE!" button at the bottom of every page to look at the entire lesson's code in full.</b> I've forced you to look at <i>this</i> page's source already.</p>

<br/>
<h2>You should be familiar with the following by now:</h2>


<?php

/*** IF-ELSE LOOPS ***/
$familiarWith = TRUE;
if($familiarWith){
	print_r('-- If-Else loops');
}
else{
	// If not, Go back here: http://www.codecademy.com/courses/web-beginner-en-QF3Wb?curriculum_id=5124ef4c78d510dd89003eb8
}

echo '<br/><br/>';

/**** SWITCH CASES ****/
$chicken = 'egg';
switch($chicken){
	case 'egg':
		echo("-- Switch-cases. <a href='index.php?lesson=switchcase' title='Review in detail'>(need to review?)</a>");
		break;
	case 'wtf is this switherydoo?':
		// Go back here: http://www.codecademy.com/courses/web-beginner-en-jZv2E?curriculum_id=5124ef4c78d510dd89003eb8
		break;
	default:
		echo "How'd I get here?!?";
}

echo '<br/><br/>';

/*** ARRAYs ****/

$whatArray = array('-- Arrays','stuff','probably other things...','and modifying them elements', 5=>'junk', 4=>'and deleting items');

$whatArray[1] = 'accessing them with purdy []';

$whatArray{2} = 'accessing them with evil {} ';

$whatArray[3] = 'and modifying their elements';

unset($whatArray[5]);

echo implode(', ', $whatArray);

if(!is_array($whatArray)){
	// Go back here http://www.codecademy.com/courses/web-beginner-en-8a35h/0?curriculum_id=5124ef4c78d510dd89003eb8
}

echo '<br/><br/>';

/*** FOR LOOPS ****/

$five = 5;
$skipMe  = FALSE;

for($index = 0; $index < $five; $index++){
	if($skipMe){
		continue;
	}
	if($index > 3){
		break;
	}
	echo "- For loops";
}


echo '<br/><br/>';

/*** FOREACH LOOPS ****/

$myWords = array('bagels'=>'are delicious', 1=>'- Iterating','through','an', 'array','using','foreach' );
foreach($myWords as $key => $word){
	if($key == 'bagels'){
		continue;
	}

	echo "{$word} ";
}



echo '<br/><br/>';

/*** WHILE LOOPS ****/

$stuttering = TRUE;

$stutterCount = 0;
while($stuttering){
	echo "-- While loops";
	if($stutterCount++ >= 5){
		$stuttering = FALSE;
	}
}


echo '<br/><br/>';

/*** DO-WHILE LOOPS ****/

do {
	echo '- Do-While loops';
} while(0 > 10)


?>

<br/><br/>

<strong>And have now dipped your toes in the steaming cesspool of randomly named and formatted built-in PHP functions:</strong><br/>

<?php


echo '<br/>';

/*** BUILT IN FUNCTIONS ****/

print("- print (usually just use echo instead...)");


echo '<br/>';
echo strtoupper("- strtoupper (aka stop yelling at me)");

echo '<br/>';

echo strtolower("- strtolower (thank you)");


echo '<br/>';
$thisReallyLongString = "to make this sentence end abruptly)";
echo "- substr (". substr($thisReallyLongString, 0, strlen($thisReallyLongString)-4);


echo '<br/>';
$strposString = "- strpos (to find the index a nested string starts)";
$lies = "LIES!!";
echo strpos($strposString, '-') !== FALSE ? $strposString : $lies;

echo '<br/>';
$float = round(M_PI, 12);
echo "- round (to make {$float} ". round($float, 2) . ')';


echo '<br/>';
echo "- floor (to make {$float} ". floor($float) . ')';


echo '<br/>';
echo "- celi (to make {$float} ". ceil($float) . ')';


echo '<br/>';
echo "- rand (to make random numbers like ". rand(0,100000000) . ')';


echo '<br/>';
$orderSentence = explode(' ', "to make this array of words ordered alphabetically");
sort($orderSentence);
echo "- sort (".implode(' ', $orderSentence).")";

?>
<br/><br/>
<p><b>AND (some of) THE REST:</b></br> count(), array_push(), array_shift(), rsort(), ksort(), usort()...
 blah blah blah (no one really memorizes these extensively for a long time... use google A LOT to find what you need)
</p>

<br/>
<h2>BUT WAIT THERE'S MORE!!! </h2><img src="http://24.media.tumblr.com/tumblr_lnik7eNjVU1qaajpfo1_500.jpg" /><br/></strong><br/>


<p><b>Up next, we'll cover creating your own functions. Click this hideous button to continue:</b></p>