-2

I need the Values of all the company names , How can I get It ...

Here is the output of json ...

Array
(
    [version] => 2
    [query] => web developer
    [location] => Hyderabad, Andhra Pradesh
    [paginationPayload] => 
    [results] => Array
        (
            [0] => Array
                (
                    [company] => IBM
                    [country] => IN
                    [date] => Mon, 02 Apr 2017 07:10:15 GMT
                    [formattedRelativeTime] => 4 days ago
                    [stations] => 
                )
            [1] => Array
                (
                    [company] => IPRISM
                    [country] => IN
                    [date] => Mon, 01 Apr 2017 07:10:15 GMT
                    [formattedRelativeTime] => 5 days ago
                    [stations] => 
                )
            [2] => Array
                (
                    [company] => Sunlife
                    [country] => IN
                    [date] => Mon, 03 Apr 2017
                    [formattedRelativeTime] => 3 days ago
                    [stations] => 
                )
     )
)

I need the Value of Every Company Listed Here In New Line ,

IBM IPRISM Sunlife

6 Answers6

1

You have to use foreach loop to achieve your result

 foreach($array['results'] as $company){
     echo $company['company'].'<br />';
 }

change the name $array with your actual array variable

Bachcha Singh
  • 3,850
  • 3
  • 24
  • 38
1

@Sharon Moore try array_column():

echo implode(" ", array_column($yourArray["results"], "company"));
lazyCoder
  • 2,544
  • 3
  • 22
  • 41
0

Try this:

foreach($obj['results'] as $data)  // On each iteration $data will be updated with 0, 1, 2 index values
{
    echo $data['jobtitle'];
}
Mayank Pandeyz
  • 25,704
  • 4
  • 40
  • 59
0

I think you could try this

 foreach ($data['result'] as $key => $value) {
    echo $value['company'];
 }
0

Try it like this,

$i=0;
foreach($obj['results'] as $res){

echo $res[$i]['company'];
$i++;

}
Abhishek Gurjar
  • 7,426
  • 10
  • 37
  • 45
0

you can try like below:

foreach($arr['results'] as $company)
{
    echo $company['company'];
}
lalithkumar
  • 3,480
  • 4
  • 24
  • 40