1--TEST-- 2mb_split() 3--SKIPIF-- 4<?php 5extension_loaded('mbstring') or die('skip mbstring not available'); 6function_exists('mb_split') or die("skip mb_split() is not available in this build"); 7?> 8--FILE-- 9<?php 10 mb_regex_set_options( '' ); 11 mb_regex_encoding( 'EUC-JP' ); 12 13 function verify_split( $spliton, $str, $count = 0 ) 14 { 15 $result1 = mb_split( $spliton, $str, $count ); 16 $result2 = preg_split( "/$spliton/", $str, $count ); 17 if ( $result1 == $result2 ) { 18 print "ok\n"; 19 } else { 20 print count($result1).'-'.count($result2)."\n"; 21 } 22 } 23 24 var_dump( mb_split( " ", "a b c d e f g" ) 25 == mb_split( "[[:space:]]", "a\nb\tc\nd e f g" ) ); 26 27 for ( $i = 1; $i < 5; ++$i ) { 28 verify_split( " ", "a\tb\tc\td e\tf g", $i ); 29 } 30 31 for ( $i = 1; $i < 5; ++$i ) { 32 verify_split( "\xa1\xa1+", "\xa1\xa1\xa1\xa2\xa2\xa1\xa1\xa1\xa1\xa1\xa1\xa2\xa2\xa1\xa1\xa1", $i ); 33 } 34?> 35--EXPECT-- 36bool(true) 37ok 38ok 39ok 40ok 41ok 422-2 433-3 444-4 45