分享一些PHP开发者实用工具(上)
来源:互联网 发布:淘宝上怎么购买av种子 编辑:程序博客网 时间:2024/06/14 21:31
今天小编给大家整理了一些php开发中可能需要用到的工具或组建,需要的朋友可以参考和收藏哦~
PHP 函数的 JavaScript 实现
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
module.exports =
function
array_sum (array) {
// eslint-disable-line camelcase
// discuss at:http://locutus.io/php/array_sum/
// original by: Kevin van Zonneveld (http://kvz.io)
// bugfixed by: Nate
// bugfixed by: Gilbert
// improved by: David Pilia (http://www.beteck.it/)
// improved by: Brett Zamir (http://brett-zamir.me)
// example 1: array_sum([4, 9, 182.6])
// returns 1: 195.6
// example 2: var $total = []
// example 2: var $index = 0.1
// example 2: for (var $y = 0; $y < 12; $y++){ $total[$y] = $y + $index }
// example 2: array_sum($total)
// returns 2: 67.2
var
key
var
sum =
0
// input sanitation
if
(
typeof
array !==
'object'
) {
return
null
}
for
(key
in
array) {
if
(!
isNaN
(
parseFloat
(array[key]))) {
sum +=
parseFloat
(array[key])
}
}
return
sum
}
点击查看>
Underscore.js 的 PHP 版
1
2
3
4
5
function
__($item=
null
) {
$__ =
new
__;
if
(func_num_args() >
0
) $__->_wrapped = $item;
return
$__;
}
点击查看>
自动生成 gitignore 文件
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
https:
//www.gitignore.io/api/laravel
# Created by https:
//www.gitignore.io/api/laravel
### Laravel ###
vendor/
node_modules/
npm-debug.log
# Laravel
4
specific
bootstrap/compiled.php
app/storage/
# Laravel
5
& Lumen specific
public
/storage
public
/hot
storage/*.key
.env.*.php
.env.php
.env
Homestead.yaml
Homestead.json
# Rocketeer PHP task runner and deployment
package
. https:
//github.com/rocketeers/rocketeer
.rocketeer/
# End of https:
//www.gitignore.io/api/laravel
点击查看>
爬虫组件
1
2
3
4
5
composer global require slince/spider *@dev
use
Slince\Spider\Spider;
$spider =
new
Spider();
$spider->run(
'http://www.baidu.com'
);
点击查看>
简单、 灵活、强大的 PHP 采集工具
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
use
QL\QueryList;
//采集某页面所有的图片
$data = QueryList::Query(
'http://cms.querylist.cc/bizhi/453.html'
,array(
//采集规则库
//'规则名' => array('jQuery选择器','要采集的属性'),
'image'
=> array(
'img'
,
'src'
)
))->data;
//打印结果
print_r($data);
//采集某页面所有的超链接
//可以先手动获取要采集的页面源码
$html = file_get_contents(
'http://cms.querylist.cc/google/list_1.html'
);
//然后可以把页面源码或者HTML片段传给QueryList
$data = QueryList::Query($html,array(
'link'
=> array(
'a'
,
'href'
)
))->data;
//打印结果
print_r($data);
在线测试采集并查看采集结果 http:
//querylist.cc/page-Querytest.html
点击查看>
在线测试代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
$array=[
[
'name'
=>
'张三'
,
'age'
=>
'23'
],
[
'name'
=>
'李四'
,
'age'
=>
'64'
],
[
'name'
=>
'王五'
,
'age'
=>
'55'
],
[
'name'
=>
'赵六'
,
'age'
=>
'66'
],
[
'name'
=>
'孙七'
,
'age'
=>
'17'
],
];
$sort = array(
'direction'
=>
'SORT_ASC'
,
//排序顺序标志 SORT_DESC 降序;SORT_ASC 升序
'field'
=>
'age'
,
//排序字段
);
$arrSort = array();
foreach($array
as
$uniqid => $row){
foreach($row AS $key=>$value){
$arrSort[$key][$uniqid] = $value;
}
}
array_multisort($arrSort[$sort[
'field'
]], constant($sort[
'direction'
]), $array);
print_r($array);
点击查看>
中文转拼音工具
1
2
3
4
5
6
7
8
9
10
11
//https://hellogithub.com/category/PHP%20%E9%A1%B9%E7%9B%AE/
use
Overtrue\Pinyin\Pinyin;
$pinyin =
new
Pinyin();
$pinyin->convert(
'带着希望去旅行,比到达终点更美好'
);
// ["dai", "zhe", "xi", "wang", "qu", "lv", "xing", "bi", "dao", "da", "zhong", "dian", "geng", "mei", "hao"]
$pinyin->convert(
'带着希望去旅行,比到达终点更美好'
, PINYIN_UNICODE);
// ["dài","zhe","xī","wàng","qù","lǚ","xíng","bǐ","dào","dá","zhōng","diǎn","gèng","měi","hǎo"]
$pinyin->convert(
'带着希望去旅行,比到达终点更美好'
, PINYIN_ASCII);
//["dai4","zhe","xi1","wang4","qu4","lv3","xing2","bi3","dao4","da2","zhong1","dian3","geng4","mei3","hao3"]
点击查看>
因为篇幅的原因,本次的分享就到这里啦,下次讲给大家带来更多php开发实用工具~
轻量级且便捷的PHP IDE PhpStorm加入在线订购快捷通道!续费更有优惠,戳这里看详情>>>
阅读全文
0 0
- 分享一些PHP开发者实用工具(上)
- Archlinux上的一些实用工具
- 分享一些php
- 转:实用工具软件分享
- 开发者分享在PC上制作iOS游戏的经验(上)
- Mac开发者必备实用工具推荐
- Mac开发者必备实用工具推荐
- Mac开发者必备实用工具推荐
- Mac开发者必备实用工具推荐
- 前端实用工具分享——字符串拼接(一)
- Android一些实用工具
- NFM一些实用工具
- 分享一些有趣的面试智力题(上)
- jquery博客分享一些php常用代码(一)
- jquery博客分享一些php常用代码(二)
- jquery博客分享一些php常用代码(三)
- jquery博客分享一些php常用代码(四)
- jquery博客分享一些php常用代码(四)
- webservice
- tomcat plugin的下载地址
- phpize动态编译报错Cannot find autoconf
- Lua基础---迭代器
- Qt之界面实现技巧(QSS)
- 分享一些PHP开发者实用工具(上)
- ThinkPHP常用内置函数
- 360WiFi文件夹存储位置如何更改
- [js]实现简单的省市二级联动下拉选择菜单
- Gradle Error:Failed to open zip file. Gradle's dependency cache may be corrupt.
- Fault
- JAVA中这些你都疏忽了吗?-标识符及其命名规范
- maven引起的xml Offending resource:
- PHP高效率写法