| Revision 20119,
852 bytes
checked in by nanasess, 15 years ago
(diff) |
|
module 以下は svn:keywords を除外
|
-
Property svn:eol-style set to
LF
|
| Line | |
|---|
| 1 | --TEST-- |
|---|
| 2 | Function -- str_split |
|---|
| 3 | --SKIPIF-- |
|---|
| 4 | <?php if (function_exists('str_split')) { echo 'skip'; } ?> |
|---|
| 5 | --FILE-- |
|---|
| 6 | <?php |
|---|
| 7 | require_once 'PHP/Compat.php'; |
|---|
| 8 | PHP_Compat::loadFunction('str_split'); |
|---|
| 9 | |
|---|
| 10 | $str = "Hello Friend"; |
|---|
| 11 | |
|---|
| 12 | // Simple |
|---|
| 13 | $arr = str_split($str); |
|---|
| 14 | print_r($arr); |
|---|
| 15 | |
|---|
| 16 | // With a chunk size specified |
|---|
| 17 | $arr = str_split($str, 3); |
|---|
| 18 | print_r($arr); |
|---|
| 19 | |
|---|
| 20 | // With chunk size bigger than the string |
|---|
| 21 | $arr = str_split($str, 60); |
|---|
| 22 | print_r($arr); |
|---|
| 23 | |
|---|
| 24 | // String that has a remainder less than the chunk size |
|---|
| 25 | $arr = str_split($str, 11); |
|---|
| 26 | print_r($arr); |
|---|
| 27 | ?> |
|---|
| 28 | --EXPECT-- |
|---|
| 29 | Array |
|---|
| 30 | ( |
|---|
| 31 | [0] => H |
|---|
| 32 | [1] => e |
|---|
| 33 | [2] => l |
|---|
| 34 | [3] => l |
|---|
| 35 | [4] => o |
|---|
| 36 | [5] => |
|---|
| 37 | [6] => F |
|---|
| 38 | [7] => r |
|---|
| 39 | [8] => i |
|---|
| 40 | [9] => e |
|---|
| 41 | [10] => n |
|---|
| 42 | [11] => d |
|---|
| 43 | ) |
|---|
| 44 | Array |
|---|
| 45 | ( |
|---|
| 46 | [0] => Hel |
|---|
| 47 | [1] => lo |
|---|
| 48 | [2] => Fri |
|---|
| 49 | [3] => end |
|---|
| 50 | ) |
|---|
| 51 | Array |
|---|
| 52 | ( |
|---|
| 53 | [0] => Hello Friend |
|---|
| 54 | ) |
|---|
| 55 | Array |
|---|
| 56 | ( |
|---|
| 57 | [0] => Hello Frien |
|---|
| 58 | [1] => d |
|---|
| 59 | ) |
|---|
Note: See
TracBrowser
for help on using the repository browser.