1--TEST--
2Test strspn() function : usage variations - with varying start and default len args
3--FILE--
4<?php
5/*
6* Testing strspn() : with varying start and default len arguments
7*/
8
9echo "*** Testing strspn() : with different start and default len values ***\n";
10
11// initialing required variables
12// defining different strings
13$strings = array(
14                   "",
15           '',
16           "\n",
17           '\n',
18           "hello\tworld\nhello\nworld\n",
19           'hello\tworld\nhello\nworld\n',
20           "1234hello45world\t123",
21           '1234hello45world\t123',
22           "hello\0world\012",
23           'hello\0world\012',
24           chr(0).chr(0),
25           chr(0)."hello\0world".chr(0),
26           chr(0).'hello\0world'.chr(0),
27           "hello".chr(0)."world",
28           'hello'.chr(0).'world',
29           "hello\0\100\xaaaworld",
30           'hello\0\100\xaaaworld'
31                   );
32
33// define the array of mask strings
34$mask_array = array(
35            "",
36            '',
37            "f\n\trelshti \l",
38            'f\n\trelsthi \l',
39            "\telh",
40            "t\ ",
41            '\telh',
42            "felh\t\ ",
43            " \t",
44                    "fhel\t\i\100\xa"
45                   );
46
47// defining the array for start values
48$start_array = array(
49            0,
50            1,
51                    2,
52            -1,
53            -2,
54            2147483647,  // max positive integer
55            -2147483648,  // min negative integer
56                   );
57
58
59// loop through each element of the arrays for str, mask and start argument
60$count = 1;
61foreach($strings as $str) {
62  echo "\n-- Iteration $count --\n";
63  foreach($mask_array as $mask) {
64    foreach($start_array as $start) {
65      var_dump( strspn($str,$mask,$start) );
66    }
67  }
68  $count++;
69}
70
71echo "Done"
72?>
73--EXPECT--
74*** Testing strspn() : with different start and default len values ***
75
76-- Iteration 1 --
77int(0)
78int(0)
79int(0)
80int(0)
81int(0)
82int(0)
83int(0)
84int(0)
85int(0)
86int(0)
87int(0)
88int(0)
89int(0)
90int(0)
91int(0)
92int(0)
93int(0)
94int(0)
95int(0)
96int(0)
97int(0)
98int(0)
99int(0)
100int(0)
101int(0)
102int(0)
103int(0)
104int(0)
105int(0)
106int(0)
107int(0)
108int(0)
109int(0)
110int(0)
111int(0)
112int(0)
113int(0)
114int(0)
115int(0)
116int(0)
117int(0)
118int(0)
119int(0)
120int(0)
121int(0)
122int(0)
123int(0)
124int(0)
125int(0)
126int(0)
127int(0)
128int(0)
129int(0)
130int(0)
131int(0)
132int(0)
133int(0)
134int(0)
135int(0)
136int(0)
137int(0)
138int(0)
139int(0)
140int(0)
141int(0)
142int(0)
143int(0)
144int(0)
145int(0)
146int(0)
147
148-- Iteration 2 --
149int(0)
150int(0)
151int(0)
152int(0)
153int(0)
154int(0)
155int(0)
156int(0)
157int(0)
158int(0)
159int(0)
160int(0)
161int(0)
162int(0)
163int(0)
164int(0)
165int(0)
166int(0)
167int(0)
168int(0)
169int(0)
170int(0)
171int(0)
172int(0)
173int(0)
174int(0)
175int(0)
176int(0)
177int(0)
178int(0)
179int(0)
180int(0)
181int(0)
182int(0)
183int(0)
184int(0)
185int(0)
186int(0)
187int(0)
188int(0)
189int(0)
190int(0)
191int(0)
192int(0)
193int(0)
194int(0)
195int(0)
196int(0)
197int(0)
198int(0)
199int(0)
200int(0)
201int(0)
202int(0)
203int(0)
204int(0)
205int(0)
206int(0)
207int(0)
208int(0)
209int(0)
210int(0)
211int(0)
212int(0)
213int(0)
214int(0)
215int(0)
216int(0)
217int(0)
218int(0)
219
220-- Iteration 3 --
221int(0)
222int(0)
223int(0)
224int(0)
225int(0)
226int(0)
227int(0)
228int(0)
229int(0)
230int(0)
231int(0)
232int(0)
233int(0)
234int(0)
235int(1)
236int(0)
237int(0)
238int(1)
239int(1)
240int(0)
241int(1)
242int(0)
243int(0)
244int(0)
245int(0)
246int(0)
247int(0)
248int(0)
249int(0)
250int(0)
251int(0)
252int(0)
253int(0)
254int(0)
255int(0)
256int(0)
257int(0)
258int(0)
259int(0)
260int(0)
261int(0)
262int(0)
263int(0)
264int(0)
265int(0)
266int(0)
267int(0)
268int(0)
269int(0)
270int(0)
271int(0)
272int(0)
273int(0)
274int(0)
275int(0)
276int(0)
277int(0)
278int(0)
279int(0)
280int(0)
281int(0)
282int(0)
283int(0)
284int(1)
285int(0)
286int(0)
287int(1)
288int(1)
289int(0)
290int(1)
291
292-- Iteration 4 --
293int(0)
294int(0)
295int(0)
296int(0)
297int(0)
298int(0)
299int(0)
300int(0)
301int(0)
302int(0)
303int(0)
304int(0)
305int(0)
306int(0)
307int(1)
308int(0)
309int(0)
310int(0)
311int(1)
312int(0)
313int(1)
314int(2)
315int(1)
316int(0)
317int(1)
318int(2)
319int(0)
320int(2)
321int(0)
322int(0)
323int(0)
324int(0)
325int(0)
326int(0)
327int(0)
328int(1)
329int(0)
330int(0)
331int(0)
332int(1)
333int(0)
334int(1)
335int(1)
336int(0)
337int(0)
338int(0)
339int(1)
340int(0)
341int(1)
342int(1)
343int(0)
344int(0)
345int(0)
346int(1)
347int(0)
348int(1)
349int(0)
350int(0)
351int(0)
352int(0)
353int(0)
354int(0)
355int(0)
356int(1)
357int(0)
358int(0)
359int(0)
360int(1)
361int(0)
362int(1)
363
364-- Iteration 5 --
365int(0)
366int(0)
367int(0)
368int(0)
369int(0)
370int(0)
371int(0)
372int(0)
373int(0)
374int(0)
375int(0)
376int(0)
377int(0)
378int(0)
379int(4)
380int(3)
381int(2)
382int(1)
383int(0)
384int(0)
385int(4)
386int(4)
387int(3)
388int(2)
389int(0)
390int(0)
391int(0)
392int(4)
393int(4)
394int(3)
395int(2)
396int(0)
397int(0)
398int(0)
399int(4)
400int(0)
401int(0)
402int(0)
403int(0)
404int(0)
405int(0)
406int(0)
407int(4)
408int(3)
409int(2)
410int(0)
411int(0)
412int(0)
413int(4)
414int(4)
415int(3)
416int(2)
417int(0)
418int(0)
419int(0)
420int(4)
421int(0)
422int(0)
423int(0)
424int(0)
425int(0)
426int(0)
427int(0)
428int(4)
429int(3)
430int(2)
431int(1)
432int(0)
433int(0)
434int(4)
435
436-- Iteration 6 --
437int(0)
438int(0)
439int(0)
440int(0)
441int(0)
442int(0)
443int(0)
444int(0)
445int(0)
446int(0)
447int(0)
448int(0)
449int(0)
450int(0)
451int(4)
452int(3)
453int(2)
454int(0)
455int(1)
456int(0)
457int(4)
458int(4)
459int(3)
460int(2)
461int(1)
462int(2)
463int(0)
464int(4)
465int(4)
466int(3)
467int(2)
468int(0)
469int(0)
470int(0)
471int(4)
472int(0)
473int(0)
474int(0)
475int(0)
476int(1)
477int(0)
478int(0)
479int(4)
480int(3)
481int(2)
482int(0)
483int(1)
484int(0)
485int(4)
486int(4)
487int(3)
488int(2)
489int(0)
490int(1)
491int(0)
492int(4)
493int(0)
494int(0)
495int(0)
496int(0)
497int(0)
498int(0)
499int(0)
500int(4)
501int(3)
502int(2)
503int(0)
504int(1)
505int(0)
506int(4)
507
508-- Iteration 7 --
509int(0)
510int(0)
511int(0)
512int(0)
513int(0)
514int(0)
515int(0)
516int(0)
517int(0)
518int(0)
519int(0)
520int(0)
521int(0)
522int(0)
523int(0)
524int(0)
525int(0)
526int(0)
527int(0)
528int(0)
529int(0)
530int(0)
531int(0)
532int(0)
533int(0)
534int(0)
535int(0)
536int(0)
537int(0)
538int(0)
539int(0)
540int(0)
541int(0)
542int(0)
543int(0)
544int(0)
545int(0)
546int(0)
547int(0)
548int(0)
549int(0)
550int(0)
551int(0)
552int(0)
553int(0)
554int(0)
555int(0)
556int(0)
557int(0)
558int(0)
559int(0)
560int(0)
561int(0)
562int(0)
563int(0)
564int(0)
565int(0)
566int(0)
567int(0)
568int(0)
569int(0)
570int(0)
571int(0)
572int(0)
573int(0)
574int(0)
575int(0)
576int(0)
577int(0)
578int(0)
579
580-- Iteration 8 --
581int(0)
582int(0)
583int(0)
584int(0)
585int(0)
586int(0)
587int(0)
588int(0)
589int(0)
590int(0)
591int(0)
592int(0)
593int(0)
594int(0)
595int(0)
596int(0)
597int(0)
598int(0)
599int(0)
600int(0)
601int(0)
602int(0)
603int(0)
604int(0)
605int(0)
606int(0)
607int(0)
608int(0)
609int(0)
610int(0)
611int(0)
612int(0)
613int(0)
614int(0)
615int(0)
616int(0)
617int(0)
618int(0)
619int(0)
620int(0)
621int(0)
622int(0)
623int(0)
624int(0)
625int(0)
626int(0)
627int(0)
628int(0)
629int(0)
630int(0)
631int(0)
632int(0)
633int(0)
634int(0)
635int(0)
636int(0)
637int(0)
638int(0)
639int(0)
640int(0)
641int(0)
642int(0)
643int(0)
644int(0)
645int(0)
646int(0)
647int(0)
648int(0)
649int(0)
650int(0)
651
652-- Iteration 9 --
653int(0)
654int(0)
655int(0)
656int(0)
657int(0)
658int(0)
659int(0)
660int(0)
661int(0)
662int(0)
663int(0)
664int(0)
665int(0)
666int(0)
667int(4)
668int(3)
669int(2)
670int(1)
671int(0)
672int(0)
673int(4)
674int(4)
675int(3)
676int(2)
677int(0)
678int(0)
679int(0)
680int(4)
681int(4)
682int(3)
683int(2)
684int(0)
685int(0)
686int(0)
687int(4)
688int(0)
689int(0)
690int(0)
691int(0)
692int(0)
693int(0)
694int(0)
695int(4)
696int(3)
697int(2)
698int(0)
699int(0)
700int(0)
701int(4)
702int(4)
703int(3)
704int(2)
705int(0)
706int(0)
707int(0)
708int(4)
709int(0)
710int(0)
711int(0)
712int(0)
713int(0)
714int(0)
715int(0)
716int(4)
717int(3)
718int(2)
719int(1)
720int(0)
721int(0)
722int(4)
723
724-- Iteration 10 --
725int(0)
726int(0)
727int(0)
728int(0)
729int(0)
730int(0)
731int(0)
732int(0)
733int(0)
734int(0)
735int(0)
736int(0)
737int(0)
738int(0)
739int(4)
740int(3)
741int(2)
742int(0)
743int(0)
744int(0)
745int(4)
746int(4)
747int(3)
748int(2)
749int(0)
750int(0)
751int(0)
752int(4)
753int(4)
754int(3)
755int(2)
756int(0)
757int(0)
758int(0)
759int(4)
760int(0)
761int(0)
762int(0)
763int(0)
764int(0)
765int(0)
766int(0)
767int(4)
768int(3)
769int(2)
770int(0)
771int(0)
772int(0)
773int(4)
774int(4)
775int(3)
776int(2)
777int(0)
778int(0)
779int(0)
780int(4)
781int(0)
782int(0)
783int(0)
784int(0)
785int(0)
786int(0)
787int(0)
788int(4)
789int(3)
790int(2)
791int(0)
792int(0)
793int(0)
794int(4)
795
796-- Iteration 11 --
797int(0)
798int(0)
799int(0)
800int(0)
801int(0)
802int(0)
803int(0)
804int(0)
805int(0)
806int(0)
807int(0)
808int(0)
809int(0)
810int(0)
811int(0)
812int(0)
813int(0)
814int(0)
815int(0)
816int(0)
817int(0)
818int(0)
819int(0)
820int(0)
821int(0)
822int(0)
823int(0)
824int(0)
825int(0)
826int(0)
827int(0)
828int(0)
829int(0)
830int(0)
831int(0)
832int(0)
833int(0)
834int(0)
835int(0)
836int(0)
837int(0)
838int(0)
839int(0)
840int(0)
841int(0)
842int(0)
843int(0)
844int(0)
845int(0)
846int(0)
847int(0)
848int(0)
849int(0)
850int(0)
851int(0)
852int(0)
853int(0)
854int(0)
855int(0)
856int(0)
857int(0)
858int(0)
859int(0)
860int(0)
861int(0)
862int(0)
863int(0)
864int(0)
865int(0)
866int(0)
867
868-- Iteration 12 --
869int(0)
870int(0)
871int(0)
872int(0)
873int(0)
874int(0)
875int(0)
876int(0)
877int(0)
878int(0)
879int(0)
880int(0)
881int(0)
882int(0)
883int(0)
884int(4)
885int(3)
886int(0)
887int(0)
888int(0)
889int(0)
890int(0)
891int(4)
892int(3)
893int(0)
894int(0)
895int(0)
896int(0)
897int(0)
898int(4)
899int(3)
900int(0)
901int(0)
902int(0)
903int(0)
904int(0)
905int(0)
906int(0)
907int(0)
908int(0)
909int(0)
910int(0)
911int(0)
912int(4)
913int(3)
914int(0)
915int(0)
916int(0)
917int(0)
918int(0)
919int(4)
920int(3)
921int(0)
922int(0)
923int(0)
924int(0)
925int(0)
926int(0)
927int(0)
928int(0)
929int(0)
930int(0)
931int(0)
932int(0)
933int(4)
934int(3)
935int(0)
936int(0)
937int(0)
938int(0)
939
940-- Iteration 13 --
941int(0)
942int(0)
943int(0)
944int(0)
945int(0)
946int(0)
947int(0)
948int(0)
949int(0)
950int(0)
951int(0)
952int(0)
953int(0)
954int(0)
955int(0)
956int(4)
957int(3)
958int(0)
959int(0)
960int(0)
961int(0)
962int(0)
963int(4)
964int(3)
965int(0)
966int(0)
967int(0)
968int(0)
969int(0)
970int(4)
971int(3)
972int(0)
973int(0)
974int(0)
975int(0)
976int(0)
977int(0)
978int(0)
979int(0)
980int(0)
981int(0)
982int(0)
983int(0)
984int(4)
985int(3)
986int(0)
987int(0)
988int(0)
989int(0)
990int(0)
991int(4)
992int(3)
993int(0)
994int(0)
995int(0)
996int(0)
997int(0)
998int(0)
999int(0)
1000int(0)
1001int(0)
1002int(0)
1003int(0)
1004int(0)
1005int(4)
1006int(3)
1007int(0)
1008int(0)
1009int(0)
1010int(0)
1011
1012-- Iteration 14 --
1013int(0)
1014int(0)
1015int(0)
1016int(0)
1017int(0)
1018int(0)
1019int(0)
1020int(0)
1021int(0)
1022int(0)
1023int(0)
1024int(0)
1025int(0)
1026int(0)
1027int(4)
1028int(3)
1029int(2)
1030int(0)
1031int(1)
1032int(0)
1033int(4)
1034int(4)
1035int(3)
1036int(2)
1037int(0)
1038int(1)
1039int(0)
1040int(4)
1041int(4)
1042int(3)
1043int(2)
1044int(0)
1045int(1)
1046int(0)
1047int(4)
1048int(0)
1049int(0)
1050int(0)
1051int(0)
1052int(0)
1053int(0)
1054int(0)
1055int(4)
1056int(3)
1057int(2)
1058int(0)
1059int(1)
1060int(0)
1061int(4)
1062int(4)
1063int(3)
1064int(2)
1065int(0)
1066int(1)
1067int(0)
1068int(4)
1069int(0)
1070int(0)
1071int(0)
1072int(0)
1073int(0)
1074int(0)
1075int(0)
1076int(4)
1077int(3)
1078int(2)
1079int(0)
1080int(1)
1081int(0)
1082int(4)
1083
1084-- Iteration 15 --
1085int(0)
1086int(0)
1087int(0)
1088int(0)
1089int(0)
1090int(0)
1091int(0)
1092int(0)
1093int(0)
1094int(0)
1095int(0)
1096int(0)
1097int(0)
1098int(0)
1099int(4)
1100int(3)
1101int(2)
1102int(0)
1103int(1)
1104int(0)
1105int(4)
1106int(4)
1107int(3)
1108int(2)
1109int(0)
1110int(1)
1111int(0)
1112int(4)
1113int(4)
1114int(3)
1115int(2)
1116int(0)
1117int(1)
1118int(0)
1119int(4)
1120int(0)
1121int(0)
1122int(0)
1123int(0)
1124int(0)
1125int(0)
1126int(0)
1127int(4)
1128int(3)
1129int(2)
1130int(0)
1131int(1)
1132int(0)
1133int(4)
1134int(4)
1135int(3)
1136int(2)
1137int(0)
1138int(1)
1139int(0)
1140int(4)
1141int(0)
1142int(0)
1143int(0)
1144int(0)
1145int(0)
1146int(0)
1147int(0)
1148int(4)
1149int(3)
1150int(2)
1151int(0)
1152int(1)
1153int(0)
1154int(4)
1155
1156-- Iteration 16 --
1157int(0)
1158int(0)
1159int(0)
1160int(0)
1161int(0)
1162int(0)
1163int(0)
1164int(0)
1165int(0)
1166int(0)
1167int(0)
1168int(0)
1169int(0)
1170int(0)
1171int(4)
1172int(3)
1173int(2)
1174int(0)
1175int(1)
1176int(0)
1177int(4)
1178int(4)
1179int(3)
1180int(2)
1181int(0)
1182int(1)
1183int(0)
1184int(4)
1185int(4)
1186int(3)
1187int(2)
1188int(0)
1189int(1)
1190int(0)
1191int(4)
1192int(0)
1193int(0)
1194int(0)
1195int(0)
1196int(0)
1197int(0)
1198int(0)
1199int(4)
1200int(3)
1201int(2)
1202int(0)
1203int(1)
1204int(0)
1205int(4)
1206int(4)
1207int(3)
1208int(2)
1209int(0)
1210int(1)
1211int(0)
1212int(4)
1213int(0)
1214int(0)
1215int(0)
1216int(0)
1217int(0)
1218int(0)
1219int(0)
1220int(4)
1221int(3)
1222int(2)
1223int(0)
1224int(1)
1225int(0)
1226int(4)
1227
1228-- Iteration 17 --
1229int(0)
1230int(0)
1231int(0)
1232int(0)
1233int(0)
1234int(0)
1235int(0)
1236int(0)
1237int(0)
1238int(0)
1239int(0)
1240int(0)
1241int(0)
1242int(0)
1243int(4)
1244int(3)
1245int(2)
1246int(0)
1247int(1)
1248int(0)
1249int(4)
1250int(4)
1251int(3)
1252int(2)
1253int(0)
1254int(1)
1255int(0)
1256int(4)
1257int(4)
1258int(3)
1259int(2)
1260int(0)
1261int(1)
1262int(0)
1263int(4)
1264int(0)
1265int(0)
1266int(0)
1267int(0)
1268int(0)
1269int(0)
1270int(0)
1271int(4)
1272int(3)
1273int(2)
1274int(0)
1275int(1)
1276int(0)
1277int(4)
1278int(4)
1279int(3)
1280int(2)
1281int(0)
1282int(1)
1283int(0)
1284int(4)
1285int(0)
1286int(0)
1287int(0)
1288int(0)
1289int(0)
1290int(0)
1291int(0)
1292int(4)
1293int(3)
1294int(2)
1295int(0)
1296int(1)
1297int(0)
1298int(4)
1299Done
1300