Created
June 7, 2012 12:53
-
-
Save rowan-m/2888666 to your computer and use it in GitHub Desktop.
Estimation Test Attempts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$string = 'It is very difficult to make a vigorous, plausible, and job-risking defense of an estimate that is derived by no quantitative method, supported by little data, and certified chiefly by the hunches of the managers.'; | |
$string = wordwrap($string, 80, '#'); | |
$length = strlen($string); | |
$wordsPerLine = array(); | |
$line = 1; | |
for ($i = 0; $i <= $length; $i++) { | |
if ($string[$i] == ' ') { | |
$wordsPerLine[$line]++; | |
} | |
if ($string[$i] == '#') { | |
$line++; | |
} | |
} | |
print_r($wordsPerLine); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$string = 'It is very difficult to make a vigorous, plausible, and job-risking defense of an estimate that is derived by no quantitative method, supported by little data, and certified chiefly by the hunches of the managers.'; | |
$string = wordwrap($string, 80, '#'); | |
$wordsPerLine = array(); | |
$lines = explode('#', $string); | |
foreach($lines as $line) { | |
$wordsPerLine[] = str_word_count($line); | |
} | |
print_r($wordsPerLine); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment