Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bug in solution of exercise 3, also update the describe of problem. #64

Merged
merged 1 commit into from
Aug 29, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion exercises/my-first-io/problem/problem.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ To read a file, you'll need to use `file_get_contents('/path/to/file')`. This me
Documentation on the `file_get_contents` function can be found by pointing your browser here:
[http://php.net/manual/en/function.file-get-contents.php]()

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.
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.

----------------------------------------------------------------------
3 changes: 1 addition & 2 deletions exercises/my-first-io/solution/solution.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?php

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