Created
June 7, 2021 06:50
-
-
Save prodhan/fa55931c27c0d49ef853a4f6d6e6a038 to your computer and use it in GitHub Desktop.
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 | |
/* Q1: Suppose this array come from back-end. data of this array can be dynamic. | |
You have to make a Dynamic HTML Output (using ul tag) based on this array, | |
where each item will fall under its parent id. | |
output will look something like this. | |
Bangladesh | |
Dhaka | |
Uttara | |
Khilgaon | |
Noyakhali | |
Maijdi | |
Canada | |
Torrento | |
*/ | |
$arr = [ | |
[ | |
"id" => 500, | |
"p_id" => 0, | |
"title" => "Bangladesh" | |
], | |
[ | |
"id" => 510, | |
"p_id" => 500, | |
"title" => "Dhaka" | |
], | |
[ | |
"id" => 511, | |
"p_id" => 510, | |
"title" => "Uttara" | |
], | |
[ | |
"id" => 512, | |
"p_id" => 510, | |
"title" => "Khailgaon" | |
], | |
[ | |
"id" => 513, | |
"p_id" => 500, | |
"title" => "NoyaKhali" | |
], | |
[ | |
"id" => 514, | |
"p_id" => 513, | |
"title" => "Maijdi" | |
], | |
[ | |
"id" => 515, | |
"p_id" => 0, | |
"title" => "Canada" | |
], | |
[ | |
"id" => 516, | |
"p_id" => 515, | |
"title" => "Toronto" | |
], | |
]; |
Amir2417
commented
Jun 21, 2022
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment