fgetcsv_variation17.phpt 22 KB

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