-2

i am laraval5.1. i am taking database table into array.

data is getting stored into stdclassobject.

i want to convert into normal array. how to do that

    $silver_plans = array();
    $silver_plans =  DB::select('select * from ins_gold ');
    print_r($silver_plans);

Dont know how to convert stdclass object into normal array

after storing database table ... by default it is storing data into into stdclass object. but i want to store into array

yergo
  • 4,761
  • 2
  • 19
  • 41

2 Answers2

0

You can try this (built in in laravel 5):

$silver_plans =  DB::select('select * from ins_gold ')->toArray();
print_r($silver_plans);
Hasan Tareque
  • 1,761
  • 11
  • 21
0

$array = (array) $yourObject;

check Convert PHP object to associative array

Community
  • 1
  • 1
Mangesh Sathe
  • 1,987
  • 4
  • 21
  • 40