if(empty($transport[count($transport)-1])) {     unset($transport[count($transport)-1]); }

Read more of this post