php preg_replace whitespace code example Example: php preg_replace whitespace $id = "aa aa"; echo $id; preg_replace('/\s+/', '_', $id); echo $id;