Php Check If Last Element Of Javascript