I just altered my script to get some additional interesting output:
$command_output = NULL;
$return_value = NULL;
$last_line_of_output = exec("cal", $command_output, $return_value);
//echo "\n=====\n";
$cal = implode("\n", $command_output);
//echo "\n=====\n";
for($i=0; $i<strlen($cal); $i++) {
echo $i . ": " . $cal[$i] . " (ord: " . ord($cal[$i]) . ")\n";
}
In the output, these lines in particular are of interest:
126: 2 (ord: 50)
127: 6 (ord: 54)
128: (ord: 32)
129: _ (ord: 95)
130: (ord: 8)
131: 2 (ord: 50)
132: _ (ord: 95)
133: (ord: 8)
134: 7 (ord: 55)
135: (ord: 32)
136: 2 (ord: 50)
137: 8 (ord: 56)
You can see that after 26, we have asci chars 32, 95, and 8 before the "2" in 27 (today's date). You also have the 95 and 8 after that "2" and then 32 following the "7" in 27. I'm not really sure what these chars mean but expect they are meaningful to a terminal window as some kind of formatting command. Consulting an ASCII chart, I see that ASCII chars 0-32 are "non-printing chars"
ASCII 8 - backspace
ASCII 32 - substitute
* ASCII 95 - underscore (i.e., "_")
I'm not sure at all, but it looks like the ASCII 32 starts and ends the altered formatting around today's date ("27") and that ASCII 95 ASCII 8 precede the affected chars. Beyond that I'm not really sure what to do with this information.