function StrGoto($mStr, $mSetChar, $mCount, $mLeft=TRUE)
// 取字串直到mSetChar在mStr中出现mCount次结束
/*
f('1a2b3c4d', '0123456789', 1, true)=''
f('1a2b3c4d', '0123456789', 2, true)='1a'
f('1a2b3c4d', '0123456789', 1, false)='d'
*/
{
  $Result = "";
  $K = 0;
  $L = strlen($mStr);
  for($I = 1; $I <= $L; $I++)
  {
    $J = $mLeft ? $I : ($L - $I + 1);
    if (strpos("\n".$mSetChar, $mStr[$J - 1])) $K++;
    if ($K >= $mCount) break;
    $Result = ($mLeft ? "" : $mStr[$J - 1]).$Result.($mLeft ? $mStr[$J - 1] : "");
  }
  return($Result);
}$a=StrGoto('1234$ddd', '$', 1);
$b=StrGoto('1234$ddd', '$', 1, FALSE);