非法字符串偏移 - 如何使用数组?

时间:2017-04-26 09:53:44

标签: php arrays string

此代码为我提供了alt,size等非法字符串偏移量。我找到了一些从字符串转换为数组的解决方案,但只在if语句中。我不太了解php,抱歉。

<?php
            $args = array( 'post_type' => 'shows', 'posts_per_page' => -1, 'orderby' =>'title');
            $shows = new WP_Query( $args );
            $theTitle = get_field('collection_brand_name',$collection->ID);
            $tmpTitle =  str_replace(' ', '-', $theTitle);
            $newTitle =  str_replace('.', '-', $tmpTitle);
            foreach( $shows as $show ) :
                $image = get_field('shows_image',$show->ID);
                 // vars
                $alt = $image['alt'];
                // thumbnail
                $thumb = $image['sizes'][ $size ];
                $width = $image['sizes'][ $size . '-width' ];
                $height = $image['sizes'][ $size . '-height' ];

                //$image = wp_get_attachment_image( $attachment_id, $imgSize );
                $date = get_field('shows_date',$show->ID);
            endforeach;?>

0 个答案:

没有答案