いつもお世話になております。
下記のように自身で用意したテーブルからprepareで出力した場合、下記のようなobject(stdClass)の配列が返されてしまい、通常のような配列の操作をすることができません。googleで調べところ、objectをArrayにcastしなければならないということみたいなのですが、いろいろな方法を試してもこれを単純な多次元の連想配列に変換することができません。
まだまだ、不慣れで申し訳ございませんが、どなたか解決法をご教示いただきたく存じます。よろしくお願い申し上げます。
$SQL1 = $wpdb->get_results( $wpdb->prepare("SELECT*FROM $wpdb->abcde")); var_dump($SQL1);
array(29) { [0]=> object(stdClass)#2101 (21) { ["id"]=> string(1) "1" ["year"]=> string(4) "2001" ["period"]=> string(15) "2001年12月期" ["op_sales"]=> string(5) "12561" ["op_profit"]=> string(4) "6166" ["ordinary_profit"]=> string(4) "5342" ["net_profit"]=> string(4) "5340" ["divi_profit"]=> string(5) "19026" ["divi_profit_total"]=> string(4) "5340" ["divi_extra"]=> string(1) "0" ["divi_extra_total"]=> string(1) "0" ["divi_total"]=> string(4) "5340" ["total_asset"]=> string(6) "256847" ["net_asset"]=> string(6) "154239" ["liability"]=> string(6) "102608" ["int_liability"]=> string(5) "78900" ["rent_income"]=> string(5) "12561" ["op_expense"]=> string(4) "6166" ["rent_expense"]=> string(4) "5737" ["dep"]=> string(4) "2169" ["NOI"]=> string(4) "8993" } [1]=> object(stdClass)#2102 (21) { ["id"]=> string(1) "2" ["year"]=> string(4) "2002" ["period"]=> string(14) "2002年6月期" ["op_sales"]=> string(5) "11259" ["op_profit"]=> string(4) "5007" ["ordinary_profit"]=> string(4) "4493" ["net_profit"]=> string(4)。。。以下省略
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。