https://cdn.statically.io/gh/dte-project/a/1e23173799f8ac7c346f345f20de4e5ccb246b1e/shell.v2.min.css
Loading...

Kamis, 03 April 2014

PHP

function array_to_list($array, $list_type = 'ul') {
$output = '<' . $list_type . '>';
foreach($array as $key => $values) {
if(is_array($values)) {
$output .= '<li><a href="#">' . $key . '</a>' . array_to_list($values, $list_type) . '</li>';
} else {
$output .= '<li><a href="#' . $values . '">' . $key . '</a></li>';
}
}
return $output . '</' . $list_type . '>';
}

Penggunaan

Ubah array $test menjadi elemen HTML daftar:

// Testing...
$test = array(
'A' => 'list-A',
'B' => 'list-B',
'C' => 'list-C',
'D' => array(
'AA' => 'list-AA',
'AB' => 'list-AB',
'AC' => 'list-AC',
'AD' => array(
'ADA' => 'list-ADA',
'ADB' => 'list-ADB',
'ADC' => 'list-ADC'
),
'AE' => 'list-AE'
),
'E' => 'list-E'
);

echo array_to_list($test, 'ol');

Akan menghasilkan ini:

View more articles

Keyword link

Subscribe via Email

Sign up by email to get the latest news from us..

Contact us

Send a message to us.

Template Hasil Cloning II | Copyright 2015 - 2016 | Rip Code by Shn | ShannenPio Cloning