1

i have an array like this..

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)

now how do i display only 'id' and 'subject' values using php??

3 Answers 3

1
foreach ($arr as $class){
   echo "Id:{$class->id} subject:{$class->subject}";
}
Sign up to request clarification or add additional context in comments.

Comments

0

You have to iterator on your array and for each items, display id and subject fields.

Pseudo - code

foreach($myArray as $item) {
    echo $item->id.' - '.$item->subject;
}

Comments

0

$arr is the array that has all elements

foreach($arr as $obj){
    echo $obj->id;
    echo $obj-subject;
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.