易截截图软件、单文件、免安装、纯绿色、仅160KB

php表达式之explode() 分割字符串

原帖地址:http://www.phpma.com/english/20071215/640.html
Description
array explode
( string separator, string string [, int limit])phpma.com
Returns an array of strings, each of which is a substring of string
formed by splitting it on boundaries formed by the string separator
. If limit
is set, the returned array will contain a maximum of limit
elements with the last element containing the rest of string
.
If separator
is an empty string (""), explode()
will return FALSE
. If separator
contains a value that is not contained in string
, then explode()
will return an array containing string
.
If the limit
parameter is negative, all components except the last limit
are returned. This feature was added in PHP
5.1.0
.
Although implode()
can, for historical reasons, accept its parameters in either order, explode()
cannot. You must ensure that the separator
argument comes before the string
argument.
注:
The limit
parameter was added in PHP
4.0.1

phpma.com
例子
1
.
explode()
examples
<?php
// Example
1
$pizza 
=
"piece
1
piece
2
piece
3
piece
4
piece
5
piece
6
"
;
$pieces
=
explode
(
" "
,
$pizza
);
echo
$pieces
[
0
];
// piece
1
echo
$pieces
[
1
];
// piece
2
// Example
2
$data
=
"foo:*:
1023
:
1000
::/home/foo:/bin/sh"
;
list(
$user
,
$pass
,
$uid
,
$gid
,
$gecos
,
$home
,
$shell
) =
explode
(
":"
,
$data
);
echo
$user
;
// foo
echo
$pass
;
// *
?>

例子
2
.
limit
parameter examples
phpma.com
<?php
$str
=
'one|two|three|four'
;
// positive limit
print_r
(
explode
(
'|'
,
$str
,
2
));
// negative limit
print_r
(
explode
(
'|'
,
$str
, -
1
));
?>

The above example will output:
Array
(
[
0
] => one
[
1
] => two|three|four
)
Array
(
[
0
] => one
[
1


相关文档:

采用PHP实现”服务器推”技术的聊天室

    * 作者: laruence(http://www.laruence.com)
    * 本文地址: http://www.laruence.com/2008/04/16/118.html
    * 转载请注明出处
传统的B/S结构的应用程序,都是采用”客户端拉”结束来实现客户端和服务器端的数据交换。
本文将通过结合Ticks(可以参看我 ......

linux mysql php apache 配置安装

  我们把下载的三个软件包放到/var/local目录下(这是笔者个人的习惯),它们都是tar.gz包,可以用命令tar -xzpvf 包名,把它们在当前目录(/var/local/)中解开:
cd /var/local
tar -xzpvf mysql-4.0.15.tar.gz
tar -xzpvf php-4.3.3.tar.gz
tar -xzpvf httpd-2.0.47.tar.gz
  解包后可以开始进入正式安装。 ......

PHP中getenv()函数

getenv()   取得系统的环境变量(预定义变量)
$spager=getenv('SERVER_NAME');
“PHP_SELF”
当前正在执行脚本的文件名,与 document root 相关。举例来说,在 URL 地址为 [url]http://example.com/test.php/foo.bar[/url] 的脚本中使用 $_SERVER['PHP_SELF'] 将会得到 /test.php/foo.bar 这个结 ......

招聘:PHP高级工程师@北京

岗位职责
1、协助系统架构设计师进行系统架构设计工作;
2、承担Web应用核心模块的设计/实现工作;
3、承担主要开发工作,对代码质量及进度负责;
4、进行关键技术验证以及技术选型工作;
5、和产品经理沟通并确定产品开发需求;
 
岗位要求
1、具有互联网领域相关项目开发工作经验,对互联网业务以及技术有相 ......

优化PHP代码的40条建议


1.如果一个方法可静态化,就对它做静态声明。速率可提升至4倍。
2.echo 比 print 快。
3.使用echo的多重参数(译注:指用逗号而不是句点)代替字符串连接。
4.在执行for循环之前确定最大循环数,不要每循环一次都计算最大值。
5.注销那些不用的变量尤其是大数组,以便释放内存。
6.尽量避免使用__get,__set,__auto ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号