1--TEST--
2Test strtok() function : basic functionality
3--FILE--
4<?php
5/* Prototype  : string strtok ( str $str, str $token )
6 * Description: splits a string (str) into smaller strings (tokens), with each token being delimited by any character from token
7 * Source code: ext/standard/string.c
8*/
9
10/*
11 * Testing strtok() : basic functionality
12*/
13
14echo "*** Testing strtok() : basic functionality ***\n";
15
16// Initialize all required variables
17$str = 'This testcase test strtok() function.';
18$token = ' ().';
19
20echo "\nThe Input string is:\n\"$str\"\n";
21echo "\nThe token string is:\n\"$token\"\n";
22
23// using strtok() with $str argument
24echo "\n--- Token 1 ---\n";
25var_dump( strtok($str, $token) );
26
27for( $i = 2; $i <=7; $i++ )  {
28  echo "\n--- Token $i ---\n";
29  var_dump( strtok($token) );
30}
31
32echo "Done\n";
33?>
34--EXPECT--
35*** Testing strtok() : basic functionality ***
36
37The Input string is:
38"This testcase test strtok() function."
39
40The token string is:
41" ()."
42
43--- Token 1 ---
44string(4) "This"
45
46--- Token 2 ---
47string(8) "testcase"
48
49--- Token 3 ---
50string(4) "test"
51
52--- Token 4 ---
53string(6) "strtok"
54
55--- Token 5 ---
56string(8) "function"
57
58--- Token 6 ---
59bool(false)
60
61--- Token 7 ---
62bool(false)
63Done
64