致命错误:不能在第151行使用字符串偏移量作为数组

时间:2013-11-28 06:59:18

标签: php arrays

我有这段代码,工作正常,但我的一个客户正在获取

  

致命错误:不能将字符串偏移用作数组

我评论了生成错误的行。

                                <?php 

                                $thumbId1 = get_field('portfolio_images'); //this is the line that generates the error



                                $portfolio_large = $thumbId1[0]['image'];

                                $mafioso_smvideo = get_field('small_video',$post->ID);



                                if($mafioso_smvideo!='') {

                                    echo do_shortcode($mafioso_smvideo);

                                }

                                elseif (!$portfolio_large == ''){ 

                                ?>

                                        <?php

                                            echo '<img src="'.aq_resize( $portfolio_large, 340, 197, true ).'" alt="'.get_the_title().'" class="categ-thumb"/>';

                                        ?>

1 个答案:

答案 0 :(得分:0)

<?php

if(is_array($thumbId1)){

$portfolio_large = $thumbId1[0]['image'];

}

?>