<?php

$str = 'Hello world //this is a comment
Testing //not testing
Test again';

echo preg_replace('~//.*$~m', '', $str);