2014-02-05 217 views
1

怎樣的foreach這個數組< a href="path-to-jpg-file">name< /a>的foreach PHP嵌套數組

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 
     ) 
) 
+4

張貼您的試過的代碼。 – Rikesh

回答

2

擴展在Roopendras,你只需要的preg_replace:

foreach($array as $value) { 
    echo '<a href="'.preg_replace('/^\d\d-/','',$value[0]).'">'.$value[1].'</a>'; 
} 
+1

+1,這是確切的答案 –