Umerm
Umerm

Reputation: 155

how to print Associative array of different size

I have this associative array in php. in which the last index has another array... i am trying to print id but unable to do so plz help me to echo the value of id

array (size=1)
  2 => 
    array (size=8)
      'id' => int 32 /// this is I want to echo
      'uid' => int 2
      'title' => string ' a type s' (length=9)
      'price' => int 555555
      'cat' => string 'Car' (length=3)
      'usage' => string 'used' (length=4)
      'desc' => string 'which don't look even slightly believable. If you are going to use a passage of Lorem Ipsum, you need to be sure there isn't anything embarrassing hidden in the middle of text. All the Lorem Ipsum gen' (length=200)
      'img' => 
        array (size=2)
          'img_id' => int 2
          'img_name' => string 'image_2014-09-18-22-10-59_541b3c53b5e12.jpeg' (length=44)

variable name of array is $ad.

        $ad_set = Array (
                    'id' => $id,  /// Want to echo this 
                    'uid' => $uId,
                    'title' => $title,
                    'price' => $price,
                    'cat' => $cat,
                    'usage' => $usage,
                    'desc' => $desc,
                    'img' => $a_img 
            );
            try {
                $ads [$count] = $ad_set;
            } catch ( Exception $exc ) {
                echo $exc->getTraceAsString ();
            }

            $count ++;
    return $ads;

Upvotes: 0

Views: 90

Answers (1)

Umerm
Umerm

Reputation: 155

Sorry the problem was in logic.. Counter was incrementing multiple times..thanks for help

Upvotes: 1

Related Questions