Revision 19792,
1004 bytes
checked in by Seasoft, 13 years ago
(diff) |
#744(PHP4 互換用途ソースを将来的に切り捨てやすい仕組みづくり)
|
Line | |
---|
1 | --TEST-- |
---|
2 | Function -- str_word_count |
---|
3 | --SKIPIF-- |
---|
4 | <?php if (function_exists('str_word_count')) { echo 'skip'; } ?> |
---|
5 | --FILE-- |
---|
6 | <?php |
---|
7 | require_once 'PHP/Compat.php'; |
---|
8 | PHP_Compat::loadFunction('str_word_count'); |
---|
9 | |
---|
10 | $str = "Hello friend, you're \r\nsdf\tlooking 3865\t9879 good to\"day, yes \"sir\" you am!"; |
---|
11 | var_dump(str_word_count($str)); |
---|
12 | print_r(str_word_count($str, 1)); |
---|
13 | print_r(str_word_count($str, 2)); |
---|
14 | |
---|
15 | $str = 'hello I am repeated repeated'; |
---|
16 | print_r(str_word_count($str, 2)); |
---|
17 | ?> |
---|
18 | --EXPECT-- |
---|
19 | int(12) |
---|
20 | Array |
---|
21 | ( |
---|
22 | [0] => Hello |
---|
23 | [1] => friend |
---|
24 | [2] => you're |
---|
25 | [3] => sdf |
---|
26 | [4] => looking |
---|
27 | [5] => good |
---|
28 | [6] => to |
---|
29 | [7] => day |
---|
30 | [8] => yes |
---|
31 | [9] => sir |
---|
32 | [10] => you |
---|
33 | [11] => am |
---|
34 | ) |
---|
35 | Array |
---|
36 | ( |
---|
37 | [0] => Hello |
---|
38 | [6] => friend |
---|
39 | [14] => you're |
---|
40 | [23] => sdf |
---|
41 | [27] => looking |
---|
42 | [48] => good |
---|
43 | [53] => to |
---|
44 | [56] => day |
---|
45 | [61] => yes |
---|
46 | [66] => sir |
---|
47 | [71] => you |
---|
48 | [75] => am |
---|
49 | ) |
---|
50 | Array |
---|
51 | ( |
---|
52 | [0] => hello |
---|
53 | [6] => I |
---|
54 | [8] => am |
---|
55 | [11] => repeated |
---|
56 | [20] => repeated |
---|
57 | ) |
---|
Note: See
TracBrowser
for help on using the repository browser.