fgetcsv_variation16.phpt 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939
  1. --TEST--
  2. Test fgetcsv() : usage variations - with default enclosure & length as 0
  3. --FILE--
  4. <?php
  5. /* Testing fgetcsv() to read a file when provided with default enclosure character
  6. and length value equal to zero
  7. */
  8. echo "*** Testing fgetcsv() : with default enclosure & length as 0 ***\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_variation16.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 0
  58. fseek($file_handle, 0, SEEK_SET);
  59. var_dump( fgetcsv($file_handle, 0, $delimiter) );
  60. // check the file pointer position and if eof
  61. var_dump( ftell($file_handle) );
  62. var_dump( feof($file_handle) );
  63. // close the file
  64. fclose($file_handle);
  65. //delete file
  66. unlink($filename);
  67. } //end of mode loop
  68. } // end of foreach
  69. echo "Done\n";
  70. ?>
  71. --EXPECT--
  72. *** Testing fgetcsv() : with default enclosure & length as 0 ***
  73. -- Testing fgetcsv() with file opened using r mode --
  74. array(2) {
  75. [0]=>
  76. string(5) "water"
  77. [1]=>
  78. string(5) "fruit"
  79. }
  80. int(12)
  81. bool(false)
  82. -- Testing fgetcsv() with file opened using rb mode --
  83. array(2) {
  84. [0]=>
  85. string(5) "water"
  86. [1]=>
  87. string(5) "fruit"
  88. }
  89. int(12)
  90. bool(false)
  91. -- Testing fgetcsv() with file opened using rt mode --
  92. array(2) {
  93. [0]=>
  94. string(5) "water"
  95. [1]=>
  96. string(5) "fruit"
  97. }
  98. int(12)
  99. bool(false)
  100. -- Testing fgetcsv() with file opened using r+ mode --
  101. array(2) {
  102. [0]=>
  103. string(5) "water"
  104. [1]=>
  105. string(5) "fruit"
  106. }
  107. int(12)
  108. bool(false)
  109. -- Testing fgetcsv() with file opened using r+b mode --
  110. array(2) {
  111. [0]=>
  112. string(5) "water"
  113. [1]=>
  114. string(5) "fruit"
  115. }
  116. int(12)
  117. bool(false)
  118. -- Testing fgetcsv() with file opened using r+t mode --
  119. array(2) {
  120. [0]=>
  121. string(5) "water"
  122. [1]=>
  123. string(5) "fruit"
  124. }
  125. int(12)
  126. bool(false)
  127. -- Testing fgetcsv() with file opened using a+ mode --
  128. array(2) {
  129. [0]=>
  130. string(5) "water"
  131. [1]=>
  132. string(5) "fruit"
  133. }
  134. int(12)
  135. bool(false)
  136. -- Testing fgetcsv() with file opened using a+b mode --
  137. array(2) {
  138. [0]=>
  139. string(5) "water"
  140. [1]=>
  141. string(5) "fruit"
  142. }
  143. int(12)
  144. bool(false)
  145. -- Testing fgetcsv() with file opened using a+t mode --
  146. array(2) {
  147. [0]=>
  148. string(5) "water"
  149. [1]=>
  150. string(5) "fruit"
  151. }
  152. int(12)
  153. bool(false)
  154. -- Testing fgetcsv() with file opened using w+ mode --
  155. array(2) {
  156. [0]=>
  157. string(5) "water"
  158. [1]=>
  159. string(5) "fruit"
  160. }
  161. int(12)
  162. bool(false)
  163. -- Testing fgetcsv() with file opened using w+b mode --
  164. array(2) {
  165. [0]=>
  166. string(5) "water"
  167. [1]=>
  168. string(5) "fruit"
  169. }
  170. int(12)
  171. bool(false)
  172. -- Testing fgetcsv() with file opened using w+t mode --
  173. array(2) {
  174. [0]=>
  175. string(5) "water"
  176. [1]=>
  177. string(5) "fruit"
  178. }
  179. int(12)
  180. bool(false)
  181. -- Testing fgetcsv() with file opened using x+ mode --
  182. array(2) {
  183. [0]=>
  184. string(5) "water"
  185. [1]=>
  186. string(5) "fruit"
  187. }
  188. int(12)
  189. bool(false)
  190. -- Testing fgetcsv() with file opened using x+b mode --
  191. array(2) {
  192. [0]=>
  193. string(5) "water"
  194. [1]=>
  195. string(5) "fruit"
  196. }
  197. int(12)
  198. bool(false)
  199. -- Testing fgetcsv() with file opened using x+t mode --
  200. array(2) {
  201. [0]=>
  202. string(5) "water"
  203. [1]=>
  204. string(5) "fruit"
  205. }
  206. int(12)
  207. bool(false)
  208. -- Testing fgetcsv() with file opened using r mode --
  209. array(2) {
  210. [0]=>
  211. string(5) "water"
  212. [1]=>
  213. string(5) "fruit"
  214. }
  215. int(12)
  216. bool(false)
  217. -- Testing fgetcsv() with file opened using rb mode --
  218. array(2) {
  219. [0]=>
  220. string(5) "water"
  221. [1]=>
  222. string(5) "fruit"
  223. }
  224. int(12)
  225. bool(false)
  226. -- Testing fgetcsv() with file opened using rt mode --
  227. array(2) {
  228. [0]=>
  229. string(5) "water"
  230. [1]=>
  231. string(5) "fruit"
  232. }
  233. int(12)
  234. bool(false)
  235. -- Testing fgetcsv() with file opened using r+ mode --
  236. array(2) {
  237. [0]=>
  238. string(5) "water"
  239. [1]=>
  240. string(5) "fruit"
  241. }
  242. int(12)
  243. bool(false)
  244. -- Testing fgetcsv() with file opened using r+b mode --
  245. array(2) {
  246. [0]=>
  247. string(5) "water"
  248. [1]=>
  249. string(5) "fruit"
  250. }
  251. int(12)
  252. bool(false)
  253. -- Testing fgetcsv() with file opened using r+t mode --
  254. array(2) {
  255. [0]=>
  256. string(5) "water"
  257. [1]=>
  258. string(5) "fruit"
  259. }
  260. int(12)
  261. bool(false)
  262. -- Testing fgetcsv() with file opened using a+ mode --
  263. array(2) {
  264. [0]=>
  265. string(5) "water"
  266. [1]=>
  267. string(5) "fruit"
  268. }
  269. int(12)
  270. bool(false)
  271. -- Testing fgetcsv() with file opened using a+b mode --
  272. array(2) {
  273. [0]=>
  274. string(5) "water"
  275. [1]=>
  276. string(5) "fruit"
  277. }
  278. int(12)
  279. bool(false)
  280. -- Testing fgetcsv() with file opened using a+t mode --
  281. array(2) {
  282. [0]=>
  283. string(5) "water"
  284. [1]=>
  285. string(5) "fruit"
  286. }
  287. int(12)
  288. bool(false)
  289. -- Testing fgetcsv() with file opened using w+ mode --
  290. array(2) {
  291. [0]=>
  292. string(5) "water"
  293. [1]=>
  294. string(5) "fruit"
  295. }
  296. int(12)
  297. bool(false)
  298. -- Testing fgetcsv() with file opened using w+b mode --
  299. array(2) {
  300. [0]=>
  301. string(5) "water"
  302. [1]=>
  303. string(5) "fruit"
  304. }
  305. int(12)
  306. bool(false)
  307. -- Testing fgetcsv() with file opened using w+t mode --
  308. array(2) {
  309. [0]=>
  310. string(5) "water"
  311. [1]=>
  312. string(5) "fruit"
  313. }
  314. int(12)
  315. bool(false)
  316. -- Testing fgetcsv() with file opened using x+ mode --
  317. array(2) {
  318. [0]=>
  319. string(5) "water"
  320. [1]=>
  321. string(5) "fruit"
  322. }
  323. int(12)
  324. bool(false)
  325. -- Testing fgetcsv() with file opened using x+b mode --
  326. array(2) {
  327. [0]=>
  328. string(5) "water"
  329. [1]=>
  330. string(5) "fruit"
  331. }
  332. int(12)
  333. bool(false)
  334. -- Testing fgetcsv() with file opened using x+t mode --
  335. array(2) {
  336. [0]=>
  337. string(5) "water"
  338. [1]=>
  339. string(5) "fruit"
  340. }
  341. int(12)
  342. bool(false)
  343. -- Testing fgetcsv() with file opened using r mode --
  344. array(2) {
  345. [0]=>
  346. string(5) "water"
  347. [1]=>
  348. string(5) "fruit"
  349. }
  350. int(16)
  351. bool(false)
  352. -- Testing fgetcsv() with file opened using rb mode --
  353. array(2) {
  354. [0]=>
  355. string(5) "water"
  356. [1]=>
  357. string(5) "fruit"
  358. }
  359. int(16)
  360. bool(false)
  361. -- Testing fgetcsv() with file opened using rt mode --
  362. array(2) {
  363. [0]=>
  364. string(5) "water"
  365. [1]=>
  366. string(5) "fruit"
  367. }
  368. int(16)
  369. bool(false)
  370. -- Testing fgetcsv() with file opened using r+ mode --
  371. array(2) {
  372. [0]=>
  373. string(5) "water"
  374. [1]=>
  375. string(5) "fruit"
  376. }
  377. int(16)
  378. bool(false)
  379. -- Testing fgetcsv() with file opened using r+b mode --
  380. array(2) {
  381. [0]=>
  382. string(5) "water"
  383. [1]=>
  384. string(5) "fruit"
  385. }
  386. int(16)
  387. bool(false)
  388. -- Testing fgetcsv() with file opened using r+t mode --
  389. array(2) {
  390. [0]=>
  391. string(5) "water"
  392. [1]=>
  393. string(5) "fruit"
  394. }
  395. int(16)
  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(5) "fruit"
  403. }
  404. int(16)
  405. bool(false)
  406. -- Testing fgetcsv() with file opened using a+b mode --
  407. array(2) {
  408. [0]=>
  409. string(5) "water"
  410. [1]=>
  411. string(5) "fruit"
  412. }
  413. int(16)
  414. bool(false)
  415. -- Testing fgetcsv() with file opened using a+t mode --
  416. array(2) {
  417. [0]=>
  418. string(5) "water"
  419. [1]=>
  420. string(5) "fruit"
  421. }
  422. int(16)
  423. bool(false)
  424. -- Testing fgetcsv() with file opened using w+ mode --
  425. array(2) {
  426. [0]=>
  427. string(5) "water"
  428. [1]=>
  429. string(5) "fruit"
  430. }
  431. int(16)
  432. bool(false)
  433. -- Testing fgetcsv() with file opened using w+b mode --
  434. array(2) {
  435. [0]=>
  436. string(5) "water"
  437. [1]=>
  438. string(5) "fruit"
  439. }
  440. int(16)
  441. bool(false)
  442. -- Testing fgetcsv() with file opened using w+t mode --
  443. array(2) {
  444. [0]=>
  445. string(5) "water"
  446. [1]=>
  447. string(5) "fruit"
  448. }
  449. int(16)
  450. bool(false)
  451. -- Testing fgetcsv() with file opened using x+ mode --
  452. array(2) {
  453. [0]=>
  454. string(5) "water"
  455. [1]=>
  456. string(5) "fruit"
  457. }
  458. int(16)
  459. bool(false)
  460. -- Testing fgetcsv() with file opened using x+b mode --
  461. array(2) {
  462. [0]=>
  463. string(5) "water"
  464. [1]=>
  465. string(5) "fruit"
  466. }
  467. int(16)
  468. bool(false)
  469. -- Testing fgetcsv() with file opened using x+t mode --
  470. array(2) {
  471. [0]=>
  472. string(5) "water"
  473. [1]=>
  474. string(5) "fruit"
  475. }
  476. int(16)
  477. bool(false)
  478. -- Testing fgetcsv() with file opened using r mode --
  479. array(3) {
  480. [0]=>
  481. string(5) "water"
  482. [1]=>
  483. string(5) "fruit"
  484. [2]=>
  485. string(3) "air"
  486. }
  487. int(20)
  488. bool(false)
  489. -- Testing fgetcsv() with file opened using rb mode --
  490. array(3) {
  491. [0]=>
  492. string(5) "water"
  493. [1]=>
  494. string(5) "fruit"
  495. [2]=>
  496. string(3) "air"
  497. }
  498. int(20)
  499. bool(false)
  500. -- Testing fgetcsv() with file opened using rt mode --
  501. array(3) {
  502. [0]=>
  503. string(5) "water"
  504. [1]=>
  505. string(5) "fruit"
  506. [2]=>
  507. string(3) "air"
  508. }
  509. int(20)
  510. bool(false)
  511. -- Testing fgetcsv() with file opened using r+ mode --
  512. array(3) {
  513. [0]=>
  514. string(5) "water"
  515. [1]=>
  516. string(5) "fruit"
  517. [2]=>
  518. string(3) "air"
  519. }
  520. int(20)
  521. bool(false)
  522. -- Testing fgetcsv() with file opened using r+b mode --
  523. array(3) {
  524. [0]=>
  525. string(5) "water"
  526. [1]=>
  527. string(5) "fruit"
  528. [2]=>
  529. string(3) "air"
  530. }
  531. int(20)
  532. bool(false)
  533. -- Testing fgetcsv() with file opened using r+t mode --
  534. array(3) {
  535. [0]=>
  536. string(5) "water"
  537. [1]=>
  538. string(5) "fruit"
  539. [2]=>
  540. string(3) "air"
  541. }
  542. int(20)
  543. bool(false)
  544. -- Testing fgetcsv() with file opened using a+ mode --
  545. array(3) {
  546. [0]=>
  547. string(5) "water"
  548. [1]=>
  549. string(5) "fruit"
  550. [2]=>
  551. string(3) "air"
  552. }
  553. int(20)
  554. bool(false)
  555. -- Testing fgetcsv() with file opened using a+b mode --
  556. array(3) {
  557. [0]=>
  558. string(5) "water"
  559. [1]=>
  560. string(5) "fruit"
  561. [2]=>
  562. string(3) "air"
  563. }
  564. int(20)
  565. bool(false)
  566. -- Testing fgetcsv() with file opened using a+t mode --
  567. array(3) {
  568. [0]=>
  569. string(5) "water"
  570. [1]=>
  571. string(5) "fruit"
  572. [2]=>
  573. string(3) "air"
  574. }
  575. int(20)
  576. bool(false)
  577. -- Testing fgetcsv() with file opened using w+ mode --
  578. array(3) {
  579. [0]=>
  580. string(5) "water"
  581. [1]=>
  582. string(5) "fruit"
  583. [2]=>
  584. string(3) "air"
  585. }
  586. int(20)
  587. bool(false)
  588. -- Testing fgetcsv() with file opened using w+b mode --
  589. array(3) {
  590. [0]=>
  591. string(5) "water"
  592. [1]=>
  593. string(5) "fruit"
  594. [2]=>
  595. string(3) "air"
  596. }
  597. int(20)
  598. bool(false)
  599. -- Testing fgetcsv() with file opened using w+t mode --
  600. array(3) {
  601. [0]=>
  602. string(5) "water"
  603. [1]=>
  604. string(5) "fruit"
  605. [2]=>
  606. string(3) "air"
  607. }
  608. int(20)
  609. bool(false)
  610. -- Testing fgetcsv() with file opened using x+ mode --
  611. array(3) {
  612. [0]=>
  613. string(5) "water"
  614. [1]=>
  615. string(5) "fruit"
  616. [2]=>
  617. string(3) "air"
  618. }
  619. int(20)
  620. bool(false)
  621. -- Testing fgetcsv() with file opened using x+b mode --
  622. array(3) {
  623. [0]=>
  624. string(5) "water"
  625. [1]=>
  626. string(5) "fruit"
  627. [2]=>
  628. string(3) "air"
  629. }
  630. int(20)
  631. bool(false)
  632. -- Testing fgetcsv() with file opened using x+t mode --
  633. array(3) {
  634. [0]=>
  635. string(5) "water"
  636. [1]=>
  637. string(5) "fruit"
  638. [2]=>
  639. string(3) "air"
  640. }
  641. int(20)
  642. bool(false)
  643. -- Testing fgetcsv() with file opened using r mode --
  644. array(3) {
  645. [0]=>
  646. string(5) "water"
  647. [1]=>
  648. string(5) "fruit"
  649. [2]=>
  650. string(43) ""
  651. This is line of text without csv fields
  652. "
  653. }
  654. int(61)
  655. bool(true)
  656. -- Testing fgetcsv() with file opened using rb mode --
  657. array(3) {
  658. [0]=>
  659. string(5) "water"
  660. [1]=>
  661. string(5) "fruit"
  662. [2]=>
  663. string(43) ""
  664. This is line of text without csv fields
  665. "
  666. }
  667. int(61)
  668. bool(true)
  669. -- Testing fgetcsv() with file opened using rt mode --
  670. array(3) {
  671. [0]=>
  672. string(5) "water"
  673. [1]=>
  674. string(5) "fruit"
  675. [2]=>
  676. string(43) ""
  677. This is line of text without csv fields
  678. "
  679. }
  680. int(61)
  681. bool(true)
  682. -- Testing fgetcsv() with file opened using r+ mode --
  683. array(3) {
  684. [0]=>
  685. string(5) "water"
  686. [1]=>
  687. string(5) "fruit"
  688. [2]=>
  689. string(43) ""
  690. This is line of text without csv fields
  691. "
  692. }
  693. int(61)
  694. bool(true)
  695. -- Testing fgetcsv() with file opened using r+b mode --
  696. array(3) {
  697. [0]=>
  698. string(5) "water"
  699. [1]=>
  700. string(5) "fruit"
  701. [2]=>
  702. string(43) ""
  703. This is line of text without csv fields
  704. "
  705. }
  706. int(61)
  707. bool(true)
  708. -- Testing fgetcsv() with file opened using r+t mode --
  709. array(3) {
  710. [0]=>
  711. string(5) "water"
  712. [1]=>
  713. string(5) "fruit"
  714. [2]=>
  715. string(43) ""
  716. This is line of text without csv fields
  717. "
  718. }
  719. int(61)
  720. bool(true)
  721. -- Testing fgetcsv() with file opened using a+ mode --
  722. array(3) {
  723. [0]=>
  724. string(5) "water"
  725. [1]=>
  726. string(5) "fruit"
  727. [2]=>
  728. string(43) ""
  729. This is line of text without csv fields
  730. "
  731. }
  732. int(61)
  733. bool(true)
  734. -- Testing fgetcsv() with file opened using a+b mode --
  735. array(3) {
  736. [0]=>
  737. string(5) "water"
  738. [1]=>
  739. string(5) "fruit"
  740. [2]=>
  741. string(43) ""
  742. This is line of text without csv fields
  743. "
  744. }
  745. int(61)
  746. bool(true)
  747. -- Testing fgetcsv() with file opened using a+t mode --
  748. array(3) {
  749. [0]=>
  750. string(5) "water"
  751. [1]=>
  752. string(5) "fruit"
  753. [2]=>
  754. string(43) ""
  755. This is line of text without csv fields
  756. "
  757. }
  758. int(61)
  759. bool(true)
  760. -- Testing fgetcsv() with file opened using w+ mode --
  761. array(3) {
  762. [0]=>
  763. string(5) "water"
  764. [1]=>
  765. string(5) "fruit"
  766. [2]=>
  767. string(43) ""
  768. This is line of text without csv fields
  769. "
  770. }
  771. int(61)
  772. bool(true)
  773. -- Testing fgetcsv() with file opened using w+b mode --
  774. array(3) {
  775. [0]=>
  776. string(5) "water"
  777. [1]=>
  778. string(5) "fruit"
  779. [2]=>
  780. string(43) ""
  781. This is line of text without csv fields
  782. "
  783. }
  784. int(61)
  785. bool(true)
  786. -- Testing fgetcsv() with file opened using w+t mode --
  787. array(3) {
  788. [0]=>
  789. string(5) "water"
  790. [1]=>
  791. string(5) "fruit"
  792. [2]=>
  793. string(43) ""
  794. This is line of text without csv fields
  795. "
  796. }
  797. int(61)
  798. bool(true)
  799. -- Testing fgetcsv() with file opened using x+ mode --
  800. array(3) {
  801. [0]=>
  802. string(5) "water"
  803. [1]=>
  804. string(5) "fruit"
  805. [2]=>
  806. string(43) ""
  807. This is line of text without csv fields
  808. "
  809. }
  810. int(61)
  811. bool(true)
  812. -- Testing fgetcsv() with file opened using x+b mode --
  813. array(3) {
  814. [0]=>
  815. string(5) "water"
  816. [1]=>
  817. string(5) "fruit"
  818. [2]=>
  819. string(43) ""
  820. This is line of text without csv fields
  821. "
  822. }
  823. int(61)
  824. bool(true)
  825. -- Testing fgetcsv() with file opened using x+t mode --
  826. array(3) {
  827. [0]=>
  828. string(5) "water"
  829. [1]=>
  830. string(5) "fruit"
  831. [2]=>
  832. string(43) ""
  833. This is line of text without csv fields
  834. "
  835. }
  836. int(61)
  837. bool(true)
  838. Done