Skip to content
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");