Last active
January 30, 2020 13:17
-
-
Save akash-coded/b86867b44781cf5bac9d20e87a7a3e87 to your computer and use it in GitHub Desktop.
Manipulating multidimensional associative arrays in PHP and using composite $_FILES[] along with foreach
This file contains hidden or 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 | |
$letters = ['a','b','c']; | |
$words = []; | |
$words['name'] = 'Akash'; | |
$words['skills'] = array(); | |
$words['vocab'] = 10; | |
$words['temp'] = array(); | |
foreach($letters as $letter) { | |
$words['skills'][] = htmlentities($letter); | |
} | |
print_r($words); | |
echo "</br>"; | |
if(in_array('a', $words['skills'])) { | |
print("Present</br>"); | |
} else { | |
print("Not there</br>"); | |
} | |
$files = ['fname' => 'pic.jpg', | |
'ftype' => 'jpg', | |
'flocation' => 'jsjasj']; | |
$words['temp'] = $files; | |
print_r($words); | |
echo "</br>"; | |
$empty_test = []; | |
$empty_test['name'] = "Hello Angelina"; | |
if(empty($empty_test)) { | |
echo "Is empty"; | |
} else { | |
echo "Not empty"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment