- print_r: documentation ( source)
- preg_match_all: documentation ( source)
- preg_replace: documentation ( source)
<?php
$h = "asdasd __asdasd__ frer __ desg df -+ br __";
preg_match_all('/_\_(.*?)_\_/i', $h, $r);
$rr = preg_replace('/_\_(.*?)_\_/i', '$$$', $h);
print_r($r);