<?php
$subject = "+-&&||!( ){ } [ ]^\"~*?:/";
$result = preg_replace('%([+\-&|!(){}[\]^"~*?:/]+)%', '\\\\$1', $subject); echo "Result 1: ". $result ."\n";
$subject = "+-&&||!( ){ } [ ]^\"~*?:/";
echo "Result 2: ". $result ."\n";
PD9waHAKCiRzdWJqZWN0ID0gIistJiZ8fCEoICl7IH0gWyBdXlwifio/Oi8iOwokcmVzdWx0ID0gcHJlZ19yZXBsYWNlKCclKFsrXC0mfCEoKXt9W1xdXiJ+Kj86L10rKSUnLCAnXFxcXCQxJywgJHN1YmplY3QpOwplY2hvICJSZXN1bHQgMTogIi4gJHJlc3VsdCAuIlxuIjsKCgokc3ViamVjdCA9ICIrLSYmfHwhKCApeyB9IFsgXV5cIn4qPzovIjsKJHJlc3VsdCA9IHByZWdfcmVwbGFjZSgnJVteXHddKyklJywgJ1xcXFwkMScsICRzdWJqZWN0KTsKZWNobyAiUmVzdWx0IDI6ICIuICRyZXN1bHQgLiJcbiI7