You have 5 "{" but only 4 "}".
A habit I've developed is to always type the closing "}" as soon as I type the opening brace.
First:
if($something == true)
{
}
Then start filling in the code for that block, indented appropriately:
if($something == true)
{
myfunction($foo, $bar);
echo "Hello, World!";
}
Developing that habit will avoid a lot of unbalanced braces.