fgetcsv_variation17.phpt 22 KB

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