Skip to content

Commit 07b2d4a

Browse files
authored
Merge pull request #64 from weichenlin/master
Fix bug in solution of exercise 3, also update the describe of problem.
2 parents ca0989b + fd56eb1 commit 07b2d4a

File tree

2 files changed

+2
-3
lines changed

2 files changed

+2
-3
lines changed

exercises/my-first-io/problem/problem.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@ To read a file, you'll need to use `file_get_contents('/path/to/file')`. This me
1212
Documentation on the `file_get_contents` function can be found by pointing your browser here:
1313
[http://php.net/manual/en/function.file-get-contents.php]()
1414

15-
If you're looking for an easy way to count the number of newlines in a string, recall the PHP function `explode` can be used to turn a string into an array of substrings and that "\n" can be used as a delimiter.
15+
If you're looking for an easy way to count the number of newlines in a string, recall the PHP function `substr_count` can be used to count the number of substring occurrences.
1616

1717
----------------------------------------------------------------------
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
<?php
22

33
$contents = file_get_contents($argv[1]);
4-
$lines = explode("\n", $contents);
5-
echo count($lines);
4+
echo substr_count($contents, "\n");

0 commit comments

Comments
 (0)