获取数组值

时间:2014-02-28 09:09:40

标签: php multidimensional-array

我的调试输出

Array ( 
    [0] => Array (
         [re_text_field_id] => No posts to display
         [re_textarea_field_id] => boring jokes
         [re_image_field_id] => Array (
             [id] => 6
             [src] => http://localhost/project/wp-content/uploads/2014/02/bg1.gif
        )
    ) [1] => Array (
         [re_text_field_id] => fuck it
         [re_textarea_field_id] => I feel dumb for asking, but how on earth would i go about using the repeatable fields in a way which outputs the fields needed
         [re_image_field_id] => Array (
             [id] => 4 [src] => http://localhost/project/wp-content/uploads/2014/02/bg-gradient1.png
         )
     )
 )

获取我使用的文本字段

$options = get_option('demo_options')
$slides = $options['re_']; 
foreach ($slides as $slide) {
echo $slide['re_textarea_field_id'];
}

但是我无法像这样获得图像路径

echo $slide['re_image _field_id'];

1 个答案:

答案 0 :(得分:1)

试试这个,检索图像的路径。需要添加['src']

echo $slide['re_image_field_id']['src'];