指定分隔符将字符串拆分为子字符串, 以 PHP 分解 v5 形式.
#Include <String.au3>
_StringExplode($sString, $sDelimiter [, $iLimit] )
$sString | 要拆分的字符串 |
$sDelimiter | 分隔符(拆分作用于整个字符串, 不是单个字符) |
$iLimit | [可选参数] 返回的最大元素 =0 : (默认)根据分隔符完全拆分每一个实例 >0 : 拆分极限(从字符串开头起,确定提取多少拆分段),剩余部分包含在最后一个元素内 |
成功: | 返回包含字符串拆分后的数组. |
#include <String.au3>
#include <Array.au3>
Local $text = "one##two##three##four##five##six##seven##eight"
Local $array1 = _StringExplode($text, "##", 0)
_ArrayDisplay($array1, "StringExplode 0")
;显示
;[0] = one
;[1] = two
;[2] = three
;[3] = four
;[4] = five
;[5] = six
;[6] = seven
;[7] = eight
Local $array2 = _StringExplode($text, "##", 4)
_ArrayDisplay($array2, "StringExplode 4")
;显示
;[0] = one
;[1] = two
;[2] = three
;[3] = four
;[4] = five##six##seven##eight
Local $array3 = _StringExplode($text, "##", -3)
_ArrayDisplay($array3, "StringExplode -3")
;显示
;[0] = one
;[1] = two
;[2] = three
;[3] = four
;[4] = five