如何将此数组传递给< a href="path-to-jpg-file">name< /a>
Array
(
[0] => Array
(
[0] => 01-siena-rosso-new.jpg
[1] => Siena Rosso
)
[1] => Array
(
[0] => 02-siena-noce-new.jpg
[1] => Siena Noce
)
[2] => Array
(
[0] => 03-zloty-dab.jpg
[1] => Złoty Dąb
)
)
答案 0 :(得分:6)
尝试这样的循环: -
foreach($array as $value) {
echo '<a href="'.$value[0].'">'.$value[1].'</a>';
}
答案 1 :(得分:2)
扩展Roopendras,你只需要preg_replace:
foreach($array as $value) {
echo '<a href="'.preg_replace('/^\d\d-/','',$value[0]).'">'.$value[1].'</a>';
}