php 按照字典序排序 微信卡券签名算法用到

代码

<?php
$data=array("api_ticket"=>"IpK_1T69hDhZkLQTlwsAXzJqxGE_7RuU_tjnx8rWC9f0pE-MqivB6oaKc0y75t9FM784OsySASrixvFffCl_3g","appid"=>"wx7f4447867a74c900","location_id"=>"0","timestamp"=>"1573537940","nonce_str"=>"667203012","card_id"=>"0","card_type"=>"0");
asort($data, SORT_STRING);  // 按键值升序排序
print_r($data);

结果

Array
(
    [location_id] => 0
    [card_id] => 0
    [card_type] => 0
    [timestamp] => 1573537940
    [nonce_str] => 667203012
    [api_ticket] => IpK_1T69hDhZkLQTlwsAXzJqxGE_7RuU_tjnx8rWC9f0pE-MqivB6oaKc0y75t9FM784OsySASrixvFffCl_3g
    [appid] => wx7f4447867a74c900
)


posted @ 2019-11-12 14:16  TBHacker  阅读(893)  评论(1编辑  收藏  举报