You are also using a comparison operator here... ( double == sign)
if (count($linkarray) == '5') {
$width == '130';
} else {
$width == '130';
}
When it looks as though you are trying to set the value instead, so change to:
if (count($linkarray) == '5') {
$width = '130';
} else {
$width = '130';
}
This has nothing to do with your parse error, but it will cause undesired results when you try to call the $width variable later in the script.