codeigniter - array to string conversion error when retrieving location from facebook graph api -


the code controller while using facebook login. here, on requesting location, value facebook. problem when feed location info on view page need name not id. says error on array string conversion.

{ "id": "1069347886434951", "name": "saugat thapa", "location": { "id": "106085869430478", "name": "kathmandu, nepal"    } }    public function web_login() {     $data['user'] = array();      // check if user logged in     if ($this->facebook->is_authenticated())     {         // user logged in, user details         $location= $this->facebook->request('get', '/me?fields=location{id,name}');         if (!isset($user['error']))         {             $data['location'] = $location;         }      }      // display view     $this->load->view('examples/web', $data); } 

on view

 <?php foreach ($location $key => $value) : ?>                  <li><?php echo $key; ?> : <?php echo $value; ?></li>              <?php endforeach; ?> 

change <?php echo $value; ?> <?php echo $value['name']; ?>

code goes in here

<?php  break; ?> // break 

break out of loop because next element in array string , produce error illegal string offset , want name it's fine


Comments