$var="##testcode##this is a ##code1## test of the ##code2## code
replacement system ##code3##";

$varParsed=strParse($var);
echo "$var<br>";
echo $varParsed;

function strParse($origString)
  {
  while ( $offset<strlen($origString) &&
!(($foundBeg=strpos($origString, "##", $offset))===FALSE))
    {
    if (($foundEnd=strpos($origString, "##", $foundBeg+2))<>FALSE)
      {
      $tmpString=substr($origString, $lastEnd, $foundBeg-$lastEnd);
      $tmpCode=substr($origString, $foundBeg+2, $foundEnd-($foundBeg+2));
      $finalString=$finalString . $tmpString . "<a
href='somewhere.php?id=$tmpCode'>$tmpCode</a>";
      $offset=$foundEnd+2;
      $lastEnd=$foundEnd+2;
      } else {
      echo "Parse Error<br>";
      break;
      }
    }
  return $finalString;
  }



On Thu, 30 Sep 2004 11:39:10 +0300, mario <[EMAIL PROTECTED]> wrote:
> Hi all
> 
> I have a string: ##CODE## and I want to replace that with <a
> href="somewhere.php?id=CODE">CODE</a>
> 
> can u help?
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
>

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to