Return to explode_variation6.phpt CVS log | Up to [ELWIX - Embedded LightWeight unIX -] / embedaddon / php / ext / standard / tests / strings |
1.1 misho 1: --TEST-- 2: Test explode() function : usage variations - misc tests 3: --FILE-- 4: <?php 5: 6: /* Prototype : array explode ( string $delimiter , string $string [, int $limit ] ) 7: * Description: Split a string by string. 8: * Source code: ext/standard/string.c 9: */ 10: 11: echo "*** Testing explode() function: misc tests ***\n"; 12: 13: $str = "one\x00two\x00three\x00four"; 14: 15: echo "\n-- positive limit with null separator --\n"; 16: $e = test_explode("\x00", $str, 2); 17: 18: echo "\n-- negative limit (since PHP 5.1) with null separator --\n"; 19: $e = test_explode("\x00", $str, -2); 20: 21: echo "\n-- unknown string --\n"; 22: $e = test_explode("fred", $str,1); 23: 24: echo "\n-- limit = 0 --\n"; 25: $e = test_explode("\x00", $str, 0); 26: 27: echo "\n-- limit = -1 --\n"; 28: $e = test_explode("\x00", $str, -1); 29: 30: echo "\n-- large limit = -100 --\n"; 31: $e = test_explode("\x00", $str, 100); 32: 33: function test_explode($delim, $string, $limit) 34: { 35: $e = explode($delim, $string, $limit); 36: foreach ( $e as $v) 37: { 38: var_dump(bin2hex($v)); 39: } 40: } 41: ?> 42: ===DONE=== 43: --EXPECT-- 44: *** Testing explode() function: misc tests *** 45: 46: -- positive limit with null separator -- 47: string(6) "6f6e65" 48: string(28) "74776f00746872656500666f7572" 49: 50: -- negative limit (since PHP 5.1) with null separator -- 51: string(6) "6f6e65" 52: string(6) "74776f" 53: 54: -- unknown string -- 55: string(36) "6f6e650074776f00746872656500666f7572" 56: 57: -- limit = 0 -- 58: string(36) "6f6e650074776f00746872656500666f7572" 59: 60: -- limit = -1 -- 61: string(6) "6f6e65" 62: string(6) "74776f" 63: string(10) "7468726565" 64: 65: -- large limit = -100 -- 66: string(6) "6f6e65" 67: string(6) "74776f" 68: string(10) "7468726565" 69: string(8) "666f7572" 70: ===DONE===