Yeah, i passed with your code, but i had to space it all out first. I also used print instead of echo (not that it would change much).
$name = "Nguyen Trung Duc";
print substr($name, rand(0, strlen($name) - 1), 1);
I don't understand why it didn't work, maybe it was because of the spacing (i doubt it). it wouldn't of been the echo part because @mtf used echo.
The code you have given us was correct.
therefore the only problem i could think of is if you had:
-> Typed it in the wrong place.
-> There was an error in another section of your code.
Hope this helped.