<?php

$x = "@hello, @@hello, @hello, @@hello";
$temp = '@hello';
$x = preg_replace("/(?<!@)".$temp."/", "replaced", $x);
echo $x;