$photo[] = (string) $post->{'photo-caption'};
$photo_post[] = substr($photo,0,320);
$img[] = (string) $post->{'photo-url'};
if($pCount==$photoPosts)
for($i=0;$i<$photoPosts;$i++)
{
if(isset($img[$i]))
{
echo "<div style='width:518px;height:250px;border-bottom: 1px solid;'><div style='width:210px;height:200px;float:left;'>".'<img style="width:200px;height:200px;" src="' . $img[$i] . '" />'."</div><div style='width:300px;height:50px;float:right;'>".$photo_post[$i]."</div></div><br>";
}
}
$pCount=$pCount+1;
这里substr不工作,我的照片说明没有显示
如果您想从$photo
提取子字符串,您应该确保$photo
是字符串而不是数组。赋值中$photo
后留下[]
如果您希望photo是一个数组,取消引用数组,如substr($photo[0], 0, 320);
。
当然,在后一种情况下,您必须为您的数组提供适当的索引。