-2

I am working arround array in php

my array

 Array
 (
   [0] => stdClass Object
    (
        [fieldId] => 2148632ds4134
        [content] => 20
    )

 )

I want display only [content] value i.e. 20 from above array.

Does anyone know how to do this ?

please help me

Steve Martin
  • 319
  • 2
  • 4
  • 10
  • possible duplicate of [Able to see a variable in print\_r()'s output, but not sure how to access it in code](http://stackoverflow.com/questions/6322084/able-to-see-a-variable-in-print-rs-output-but-not-sure-how-to-access-it-in-c) – hakre Aug 24 '13 at 11:35
  • I bet that is not your concrete programming question. You should better describe what in concrete you'd like to know. Also take care when using `print_r`, it does not show the correct keys/properties all the time. – hakre Aug 24 '13 at 11:37

6 Answers6

2

Try like

echo $my_arr[0]->content;
GautamD31
  • 28,552
  • 10
  • 64
  • 85
  • It probably would be a bit too much now asking "Oh PHP has objects?", right? :) I was just fooling around a bit. – hakre Aug 24 '13 at 12:16
2

You can do like this. I assume your array variable is $your_array

echo $your_array[0]->content;
som
  • 4,650
  • 2
  • 21
  • 36
0
var_dump($my_array->content);
Rahul
  • 1,181
  • 1
  • 11
  • 20
0

Add this function to your database abstraction layer class:

function fetchColumn($index) {
    array_map(create_function('$a', 'return $a["'.$index.'"];'),
        $this->fetchAll());
}

Then you use it like, $data = $MyApp->dbo->fetchColumn("content");

Ozzy
  • 8,244
  • 7
  • 55
  • 95
0

You can also try this

echo $custome_array[0]->content;
Love Trivedi
  • 3,899
  • 3
  • 20
  • 26
0

Please try below code

print_r($my_array->content);
Nalaka526
  • 11,278
  • 21
  • 82
  • 116
Guru
  • 621
  • 1
  • 4
  • 12