Skip to content

Instantly share code, notes, and snippets.

@akash-coded
Last active January 30, 2020 13:17
Show Gist options
  • Save akash-coded/b86867b44781cf5bac9d20e87a7a3e87 to your computer and use it in GitHub Desktop.
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
<?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