処理内容
閲覧数:867
投稿日:2019-01-13
更新日:2019-01-13
「order_no」で昇順ソート。
「counter_at」で降順ソート。
但し、「counter_at」は入力間違いのため存在しない
コード
foreach ($categoryList as $key => $val){ $sort_key1[$key] = $val['order_no']; $sort_key2[$key] = $val['counter_at']; array_multisort($sort_key1, SORT_ASC, $sort_key2, SORT_DESC, $categoryList); }
結果
( [0] => Array ( [category_id] => 5 [category] => 初めに [parent_id] => 0 [cnt] => 1 [parent_category] => 初めに [order_no] => 1 [cntall] => 1 ) [1] => Array ( [category_id] => 1 [category] => 法律 [parent_id] => 0 [cnt] => 1 [parent_category] => 法律 [order_no] => 2 [cntall] => 1 ) [2] => Array ( [category_id] => 2 [category] => 決済サービス [parent_id] => 0 [cnt] => 0 [parent_category] => 決済サービス [order_no] => 2 [cntall] => 12 ) [3] => Array ( [category_id] => 18 [category] => 集合知 [parent_id] => 0 [cnt] => 0 [parent_category] => 集合知 [order_no] => 2 [cntall] => 0 ) [4] => Array ( [category_id] => 19 [category] => 数学 [parent_id] => 0 [cnt] => 0 [parent_category] => 数学 [order_no] => 2 [cntall] => 0 ) [5] => Array ( [category_id] => 20 [category] => 有料会員制のオンラインサロンサービス [parent_id] => 21 [cnt] => 1 [parent_category] => 課金販売できるプラットフォーム [order_no] => 2 [cntall] => 1 ) [6] => Array ( [category_id] => 21 [category] => 課金販売できるプラットフォーム [parent_id] => 0 [cnt] => 1 [parent_category] => 課金販売できるプラットフォーム [order_no] => 2 [cntall] => 8 ) [7] => Array ( [category_id] => 22 [category] => デジタルコンテンツ販売可能なサービス [parent_id] => 21 [cnt] => 2 [parent_category] => 課金販売できるプラットフォーム [order_no] => 2 [cntall] => 2 ) [8] => Array ( [category_id] => 23 [category] => UML [parent_id] => 1 [cnt] => 0 [parent_category] => 法律 [order_no] => 2 [cntall] => 0 ) [9] => Array ( [category_id] => 24 [category] => 出力バッファリング制御 [parent_id] => 7 [cnt] => 0 [parent_category] => その他 [order_no] => 2 [cntall] => 0 ) [10] => Array ( [category_id] => 25 [category] => 機械学習 [parent_id] => 0 [cnt] => 0 [parent_category] => 機械学習 [order_no] => 2 [cntall] => 0 ) [11] => Array ( [category_id] => 26 [category] => パッケージ管理 [parent_id] => 1 [cnt] => 0 [parent_category] => 法律 [order_no] => 2 [cntall] => 0 ) [12] => Array ( [category_id] => 27 [category] => サーバ [parent_id] => 5 [cnt] => 0 [parent_category] => 初めに [order_no] => 2 [cntall] => 0 ) [13] => Array ( [category_id] => 28 [category] => HTTPクライアント [parent_id] => 5 [cnt] => 0 [parent_category] => 初めに [order_no] => 2 [cntall] => 0 ) [14] => Array ( [category_id] => 29 [category] => 「支払、出金」機能を有する決済系サービス表 [parent_id] => 2 [cnt] => 1 [parent_category] => 決済サービス [order_no] => 2 [cntall] => 1 ) [15] => Array ( [category_id] => 30 [category] => 画像 [parent_id] => 0 [cnt] => 0 [parent_category] => 画像 [order_no] => 2 [cntall] => 0 ) [16] => Array ( [category_id] => 31 [category] => デジタル回路 [parent_id] => 0 [cnt] => 0 [parent_category] => デジタル回路 [order_no] => 2 [cntall] => 0 ) [17] => Array ( [category_id] => 32 [category] => Linux [parent_id] => 0 [cnt] => 0 [parent_category] => Linux [order_no] => 2 [cntall] => 0 ) [18] => Array ( [category_id] => 33 [category] => デーモン [parent_id] => 32 [cnt] => 0 [parent_category] => Linux [order_no] => 2 [cntall] => 0 ) [19] => Array ( [category_id] => 34 [category] => スクリプト [parent_id] => 0 [cnt] => 0 [parent_category] => スクリプト [order_no] => 2 [cntall] => 0 ) [20] => Array ( [category_id] => 35 [category] => シェルスクリプト [parent_id] => 34 [cnt] => 0 [parent_category] => スクリプト [order_no] => 2 [cntall] => 0 ) [21] => Array ( [category_id] => 36 [category] => クローラ [parent_id] => 37 [cnt] => 0 [parent_category] => 検索エンジン [order_no] => 2 [cntall] => 0 ) [22] => Array ( [category_id] => 37 [category] => 検索エンジン [parent_id] => 0 [cnt] => 0 [parent_category] => 検索エンジン [order_no] => 2 [cntall] => 0 ) [23] => Array ( [category_id] => 38 [category] => 全文検索エンジン [parent_id] => 37 [cnt] => 0 [parent_category] => 検索エンジン [order_no] => 2 [cntall] => 0 ) [24] => Array ( [category_id] => 39 [category] => 形態素解析 [parent_id] => 0 [cnt] => 0 [parent_category] => 形態素解析 [order_no] => 2 [cntall] => 0 ) [25] => Array ( [category_id] => 40 [category] => C言語 [parent_id] => 41 [cnt] => 0 [parent_category] => 言語 [order_no] => 2 [cntall] => 0 ) [26] => Array ( [category_id] => 41 [category] => 言語 [parent_id] => 0 [cnt] => 0 [parent_category] => 言語 [order_no] => 2 [cntall] => 0 ) [27] => Array ( [category_id] => 42 [category] => Markdown [parent_id] => 41 [cnt] => 0 [parent_category] => 言語 [order_no] => 2 [cntall] => 0 ) [28] => Array ( [category_id] => 43 [category] => 決済サービス比較 [parent_id] => 2 [cnt] => 1 [parent_category] => 決済サービス [order_no] => 2 [cntall] => 1 ) [29] => Array ( [category_id] => 44 [category] => 設計 [parent_id] => 1 [cnt] => 0 [parent_category] => 法律 [order_no] => 2 [cntall] => 0 ) [30] => Array ( [category_id] => 45 [category] => データ圧縮 [parent_id] => 0 [cnt] => 0 [parent_category] => データ圧縮 [order_no] => 2 [cntall] => 0 ) [31] => Array ( [category_id] => 46 [category] => 単位 [parent_id] => 0 [cnt] => 0 [parent_category] => 単位 [order_no] => 2 [cntall] => 0 ) [32] => Array ( [category_id] => 47 [category] => 決済 [parent_id] => 8 [cnt] => 5 [parent_category] => Webサービスビジネス [order_no] => 2 [cntall] => 5 ) [33] => Array ( [category_id] => 48 [category] => 装置 [parent_id] => 0 [cnt] => 0 [parent_category] => 装置 [order_no] => 2 [cntall] => 0 ) [34] => Array ( [category_id] => 49 [category] => API [parent_id] => 0 [cnt] => 0 [parent_category] => API [order_no] => 2 [cntall] => 0 ) [35] => Array ( [category_id] => 50 [category] => HTTP [parent_id] => 5 [cnt] => 0 [parent_category] => 初めに [order_no] => 2 [cntall] => 0 ) [36] => Array ( [category_id] => 51 [category] => 正規表現 [parent_id] => 2 [cnt] => 0 [parent_category] => 決済サービス [order_no] => 2 [cntall] => 0 ) [37] => Array ( [category_id] => 52 [category] => OS [parent_id] => 0 [cnt] => 0 [parent_category] => OS [order_no] => 2 [cntall] => 0 ) [38] => Array ( [category_id] => 53 [category] => 認証プロトコル [parent_id] => 49 [cnt] => 0 [parent_category] => API [order_no] => 2 [cntall] => 0 ) [39] => Array ( [category_id] => 54 [category] => 課金 [parent_id] => 0 [cnt] => 9 [parent_category] => 課金 [order_no] => 2 [cntall] => 9 ) [40] => Array ( [category_id] => 55 [category] => 商取引 [parent_id] => 0 [cnt] => 1 [parent_category] => 商取引 [order_no] => 2 [cntall] => 1 ) [41] => Array ( [category_id] => 9 [category] => クラウドファンディング [parent_id] => 21 [cnt] => 2 [parent_category] => 課金販売できるプラットフォーム [order_no] => 4 [cntall] => 2 ) [42] => Array ( [category_id] => 4 [category] => software [parent_id] => 0 [cnt] => 0 [parent_category] => software [order_no] => 5 [cntall] => 0 ) [43] => Array ( [category_id] => 3 [category] => リリース [parent_id] => 1 [cnt] => 0 [parent_category] => 法律 [order_no] => 999 [cntall] => 0 ) [44] => Array ( [category_id] => 6 [category] => 「チャージ、支払、送金」機能を有する決済系サービス [parent_id] => 2 [cnt] => 1 [parent_category] => 決済サービス [order_no] => 999 [cntall] => 1 ) [45] => Array ( [category_id] => 7 [category] => その他 [parent_id] => 0 [cnt] => 0 [parent_category] => その他 [order_no] => 999 [cntall] => 0 ) [46] => Array ( [category_id] => 8 [category] => Webサービスビジネス [parent_id] => 0 [cnt] => 2 [parent_category] => Webサービスビジネス [order_no] => 999 [cntall] => 7 ) [47] => Array ( [category_id] => 10 [category] => ライブ配信サービス [parent_id] => 21 [cnt] => 1 [parent_category] => 課金販売できるプラットフォーム [order_no] => 999 [cntall] => 1 ) [48] => Array ( [category_id] => 11 [category] => テスト [parent_id] => 0 [cnt] => 0 [parent_category] => テスト [order_no] => 999 [cntall] => 0 ) [49] => Array ( [category_id] => 12 [category] => セキュリティ [parent_id] => 0 [cnt] => 0 [parent_category] => セキュリティ [order_no] => 999 [cntall] => 0 ) [50] => Array ( [category_id] => 13 [category] => クリエイター支援プラットフォーム [parent_id] => 21 [cnt] => 1 [parent_category] => 課金販売できるプラットフォーム [order_no] => 999 [cntall] => 1 ) [51] => Array ( [category_id] => 14 [category] => 「支払」機能を有する決済系サービス [parent_id] => 2 [cnt] => 6 [parent_category] => 決済サービス [order_no] => 999 [cntall] => 6 ) [52] => Array ( [category_id] => 15 [category] => バージョン管理システム [parent_id] => 1 [cnt] => 0 [parent_category] => 法律 [order_no] => 999 [cntall] => 0 ) [53] => Array ( [category_id] => 16 [category] => 「チャージ、支払、送金、出金」機能を有する決済系サービス [parent_id] => 2 [cnt] => 3 [parent_category] => 決済サービス [order_no] => 999 [cntall] => 3 ) [54] => Array ( [category_id] => 17 [category] => 統計 [parent_id] => 0 [cnt] => 0 [parent_category] => 統計 [order_no] => 999 [cntall] => 0 ) )