Esempio n. 1
0
<?php 
use php\lib\Str as str;
echo "--test-split\n";
echo "split('f,o,o,b,a,r', ',') == ";
var_dump(str::split('f,o,o,b,a,r', ','));
echo "split('f,o,o,b,a,r', ',', 3) == ";
var_dump(str::split('f,o,o,b,a,r', ',', 3));
echo "split('foobar', ',', 3) == ";
var_dump(str::split('foobar', ',', 3));
echo "split('foo,,bar', ',') == ";
var_dump(str::split('foo,,bar', ','));
echo "split('foo,,bar', ',,') == ";
var_dump(str::split('foo,,bar', ',,'));
echo "--test-join\n";
echo "join([foo,bar], ',') == " . str::join(['foo', 'bar'], ','), "\n";
echo "join([foo,bar], ',,') == " . str::join(['foo', 'bar'], ',,'), "\n";
?>
--EXPECT--
--test-split
split('f,o,o,b,a,r', ',') == array(6) {
  [0]=>
  string(1) "f"
  [1]=>
  string(1) "o"
  [2]=>
  string(1) "o"
  [3]=>
  string(1) "b"
  [4]=>
  string(1) "a"
  [5]=>