1--TEST-- 2Test strspn() function : usage variations - with varying mask & default start and len args 3--FILE-- 4<?php 5/* 6* Testing strspn() : with varying mask and default start and len arguments 7*/ 8 9echo "*** Testing strspn() : with different mask strings and default start and len arguments ***\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 48// loop through each element of the array for mask argument 49 50$count = 1; 51foreach($strings as $str) { 52 echo "\n-- Iteration $count --\n"; 53 foreach($mask_array as $mask) { 54 var_dump( strspn($str,$mask) ); 55 } 56 $count++; 57} 58 59echo "Done" 60?> 61--EXPECT-- 62*** Testing strspn() : with different mask strings and default start and len arguments *** 63 64-- Iteration 1 -- 65int(0) 66int(0) 67int(0) 68int(0) 69int(0) 70int(0) 71int(0) 72int(0) 73int(0) 74int(0) 75 76-- Iteration 2 -- 77int(0) 78int(0) 79int(0) 80int(0) 81int(0) 82int(0) 83int(0) 84int(0) 85int(0) 86int(0) 87 88-- Iteration 3 -- 89int(0) 90int(0) 91int(1) 92int(0) 93int(0) 94int(0) 95int(0) 96int(0) 97int(0) 98int(1) 99 100-- Iteration 4 -- 101int(0) 102int(0) 103int(1) 104int(2) 105int(0) 106int(1) 107int(1) 108int(1) 109int(0) 110int(1) 111 112-- Iteration 5 -- 113int(0) 114int(0) 115int(4) 116int(4) 117int(4) 118int(0) 119int(4) 120int(4) 121int(0) 122int(4) 123 124-- Iteration 6 -- 125int(0) 126int(0) 127int(4) 128int(4) 129int(4) 130int(0) 131int(4) 132int(4) 133int(0) 134int(4) 135 136-- Iteration 7 -- 137int(0) 138int(0) 139int(0) 140int(0) 141int(0) 142int(0) 143int(0) 144int(0) 145int(0) 146int(0) 147 148-- Iteration 8 -- 149int(0) 150int(0) 151int(0) 152int(0) 153int(0) 154int(0) 155int(0) 156int(0) 157int(0) 158int(0) 159 160-- Iteration 9 -- 161int(0) 162int(0) 163int(4) 164int(4) 165int(4) 166int(0) 167int(4) 168int(4) 169int(0) 170int(4) 171 172-- Iteration 10 -- 173int(0) 174int(0) 175int(4) 176int(4) 177int(4) 178int(0) 179int(4) 180int(4) 181int(0) 182int(4) 183 184-- Iteration 11 -- 185int(0) 186int(0) 187int(0) 188int(0) 189int(0) 190int(0) 191int(0) 192int(0) 193int(0) 194int(0) 195 196-- Iteration 12 -- 197int(0) 198int(0) 199int(0) 200int(0) 201int(0) 202int(0) 203int(0) 204int(0) 205int(0) 206int(0) 207 208-- Iteration 13 -- 209int(0) 210int(0) 211int(0) 212int(0) 213int(0) 214int(0) 215int(0) 216int(0) 217int(0) 218int(0) 219 220-- Iteration 14 -- 221int(0) 222int(0) 223int(4) 224int(4) 225int(4) 226int(0) 227int(4) 228int(4) 229int(0) 230int(4) 231 232-- Iteration 15 -- 233int(0) 234int(0) 235int(4) 236int(4) 237int(4) 238int(0) 239int(4) 240int(4) 241int(0) 242int(4) 243 244-- Iteration 16 -- 245int(0) 246int(0) 247int(4) 248int(4) 249int(4) 250int(0) 251int(4) 252int(4) 253int(0) 254int(4) 255 256-- Iteration 17 -- 257int(0) 258int(0) 259int(4) 260int(4) 261int(4) 262int(0) 263int(4) 264int(4) 265int(0) 266int(4) 267Done 268