Because the string doesn't have so many indexes! The index starts with 0. Just change <= to < Like this:
<?php
$string = "Lt4";
//^^^-Index 2
//||-Index 1
//|-Index 0
$getl = strlen($string); //Length: 3
for($i = 0; $i < $getl; $i++) { //i -> 0, 1, 2
echo $string[$i]; //L, t, 4
}
?>
Iteration Overview:
Variables Condition Output
| $i | $getl | $i < $getl = ? | $string[$i]
-----------------------------------------------------------------------------
Start: | 0 | 3 |
Iteration 1: | 0 | 3 | 0 < 3 = TRUE | L (Index 0)
Iteration 2: | 1 | 3 | 1 < 3 = TRUE | t (Index 1)
Iteration 3: | 2 | 3 | 2 < 3 = TRUE | 4 (Index 2)
Iteration 4: | 3 | 3 | 3 < 3 = FALSE | [OFFSET]
| | | |
End | 3 | 3 | |
| | | |
Output:
Lt4
$i<$getland not$i<=$getl.