Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
php-arrays/index.php
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
55 lines (46 sloc)
1.11 KB
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
<html> | |
<head> | |
<title>Accessing Elements</title> | |
</head> | |
<body> | |
<?php | |
error_reporting(E_ALL); | |
ini_set('display_errors', 1); | |
?> | |
<p> | |
<?php | |
$tens = array(10, 20, 30, 40, 50); | |
echo $tens[2] | |
?> | |
</p> | |
<p> | |
<?php | |
$tens = array(10, 20, 30, 40, 50); | |
echo $tens{4}; | |
?> | |
</p> | |
<p> | |
<?php | |
$languages = array("HTML/CSS", | |
"JavaScript", "PHP", "Python", "Ruby"); | |
// Write the code to modify | |
// the $languages array! | |
$languages[3] = 'SCSS'; | |
echo $languages{3}; | |
?> | |
</p> | |
<?php | |
$languages = array("HTML/CSS", | |
"JavaScript", "PHP", "Python", "Ruby"); | |
// Write the code to remove Python here! | |
unset($languages[3]); | |
// Write your code above this line. Don't | |
// worry about the code below just yet; we're | |
// using it to print the new array out for you! | |
foreach($languages as $lang) { | |
print "<p>$lang</p>"; | |
} | |
?> | |
</p> | |
</body> | |
</html> |