您好,欢迎光临! 推荐您使用Chrome浏览器访问本站。

PHP去除BOM头

687 views
PHP去除BOM头当解码的string有BOM头的时候json_decode会解析失败,我们需先去除BOM头。函数如下: function removeBOM($str = '') { if (substr($str, 0,3) == pack("CCC",0xef,0xbb,0xbf)) { $str = substr($str, 3); } return $str; } 其他方式: $result = trim($str, "\xEF\xBB\xBF"); print_r(json_decode($str, true)); exit; $result = @iconv("UTF-8", "GBK//IGNORE", $str); $result = @iconv("GBK", "UTF-8//IGNORE", $str); print_r(j......

xampp及php安装oauth扩展

1,118 views
xampp及php安装oauth扩展最近公司在做magento二次开发,需要将我们的工作流系统通过oauth连上magento,所以需要让php支援oauth扩展,在网上搜了下找到解决方法。 oauth官方下载地址:http://pecl.php.net/package/oauth windows下安装(xampp方法相同): 从http://pecl.php.net/package/oauth/1.2.3/windows下载你对应php版本的oauth 解压将文件夹中php_oauth.dll放入php/ext 更改 php.ini 加载 oauth extension=php_oauth.dll 重启apache 用phpinfo ()查看是否成功: 成功后信息应该如下: OAuth OAuth support enabled PLAINTEXT support enabled R......

PHP mysql 计算两个经纬度坐标距离

944 views
PHP mysql 计算两个经纬度坐标距离mysql版 SELECT 2 * 6378.137 * ASIN( SQRT( POW( SIN( PI( ) * ( 114.09576416015625 - 114.1798 ) /360 ) , 2 ) + COS( PI( ) * 114.09576416015625 /180 ) * COS( 114.1798 * PI( ) /180 ) * POW( SIN( PI( ) * ( 22.3932534047735 - 114.1798 ) /360 ) , 2 ) ) ) AS a FROM dual php版 function rad($d) { return $d * 3.1415926535898 / 180.0; } function GetDistance($lat1, $lng1, $lat2, $lng2) { $EARTH_RADIUS = 6378.137; //公里 $radLat1 = rad($lat1); $radLat2 = rad($lat2); $a = $radLat1 – $ra......

php数组分组

903 views
php数组分组 $order_item = Array ( 0 => Array ( 'order_id' => 1111 ,'item_id' => 1, 'pro_id' => 1, 'pro_name' => 1111 ,'buy_num' => 5), 1 => Array ( 'order_id' => 1111 ,'item_id' => 2 ,'pro_id' => 2 ,'pro_name' => 2222, 'buy_num' => 5 ), 2 => Array ( 'order_id' => 2222 ,'item_id' => 3 ,'pro_id' => 1 ,'pro_name' => 2222, 'buy_num' => 1 ), 3 => Array ( 'order_id' => 2222 ,'item_id' => 4 ,'pro_id' => 2 ,'pro_name' => 2222, 'buy_n......

PHP一维数组二维数组去重

746 views
PHP一维数组二维数组去重1、一维去重 用自带的array_unique 2、二维去重 function array_unique_2d($array){ foreach ($array as $v){ $v = join(“,”,$v); //降维,也可以用implode,将一维数组转换为用逗号连接的字符串 $temp[] = $v; } // www.jbxue.com $temp = array_unique($temp); //去掉重复的字符串,也就是重复的一维数组 foreach ($temp as $k => $v){ $temp[$k] = explode(“,”,$v); //再将拆开的数组重新组装 } return $temp; } 调用:array_unique_2d($arr);