I modified your post to use the [noparse]
bbcode tags rather than the generic [code] bbcode tags[/noparse] so that syntax highlighting (something your editor should be doing anyway!) is performed.
Having done that, you should notice that the color-coding goes awry after the line where you define [b]$result[/b]. Further inspection of that line reveals a missing string delimiter (a double quote, to be exact).
EDIT: Also, as dagon pointed out in your duplicate thread (which has been merged/deleted), please do [b]not[/b] cross-post the same topic across multiple forums.