Skip to content

Instantly share code, notes, and snippets.

@rowan-m
Created June 7, 2012 12:53
Show Gist options
  • Save rowan-m/2888666 to your computer and use it in GitHub Desktop.
Save rowan-m/2888666 to your computer and use it in GitHub Desktop.
Estimation Test Attempts
<?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);
<?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