1

私はこのような配列を持っています..

array (size=15)
0 => 
object(stdClass)[1]
  public 'id' => string '252bb4ffbc' (length=10)
  public 'title' => string '' (length=0)
  public 'subject' => string 'Monthly Volunteer Newsletter' (length=28)
  public 'send_time' => string '2011-10-18 21:15:45' (length=19)
  public 'type' => string 'regular' (length=7)
1 => 
object(stdClass)[2]
  public 'id' => string '3e9e5cb3c2' (length=10)
  public 'title' => string 'November 2011' (length=13)
  public 'subject' => string 'Children's Bureau Volunteer Newsletter' (length=38)
  public 'send_time' => string '2011-11-08 19:49:55' (length=19)
  public 'type' => string 'regular' (length=7)
2 => 
object(stdClass)[3]
  public 'id' => string '0608fee9c1' (length=10)
  public 'title' => string '' (length=0)
  public 'subject' => string 'Children's Bureau Monthly Volunteer Newsletter December  2011' (length=60)
  public 'send_time' => string '2011-12-28 17:32:29' (length=19)
  public 'type' => string 'regular' (length=7)

PHPを使用して「id」と「subject」の値のみを表示するにはどうすればよいですか??

4

3 に答える 3

1
foreach ($arr as $class){
   echo "Id:{$class->id} subject:{$class->subject}";
}
于 2013-11-11T07:36:14.357 に答える
0

$arr はすべての要素を持つ配列です

foreach($arr as $obj){
    echo $obj->id;
    echo $obj-subject;
}
于 2013-11-11T07:36:01.613 に答える
0

配列を反復処理し、アイテムごとに id と subject フィールドを表示する必要があります。

疑似 - コード

foreach($myArray as $item) {
    echo $item->id.' - '.$item->subject;
}
于 2013-11-11T07:38:14.180 に答える