易截截图软件、单文件、免安装、纯绿色、仅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系列教程】(4)——PHP的变量

很荣幸上篇文章被版主推荐到首页了,心里算是激动了一把,继续努力学习中吧。本章主要介绍PHP中的变量。主要包括:预定义变量、变量范围、可变变量以及PHP的外部变量等。
一、基础知识
PHP 中一个美元符号后面跟上一个变量名称,即表示一个变量。变量的名称是对大小写敏感的。
变量名与 PHP 中其它的标签一样遵循相同的 ......

delphi 编写的com 对象 用php调用的实例

delphi 编写的com 对象 用php调用

实例
delphi:
function Tmyxml.Get_xml: WideString;
begin
      Get_xml:='wo shi a lei!';
end;
function Tmyxml.Get_xmldata: WideString;
var
xmlStr:string;
begin
  xmlStr := '<?xml   version="1.0" & ......

PHP自学日记


--------------01-05--------------------
*
*              文件操作
*
---------------------------------------
读取整个文件: readfile(), fpassthru(), file()
读取一个字符: fgetc()
读取任意长度: fread()
查看文件是否存在: file_exis ......

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中的MYSQL常用函数总结

PHP中的MYSQL常用函数总结
1、mysql_connect()-建立数据库连接
格式:
    resource mysql_connect([string hostname [:port] [:/path/to/socket] [, string username] [, string password]])
例:
    $conn = @mysql_connect("localhost", "username", "password") or dir( ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号