<?php

$haystack = $_POST['haystack']; if ($haystack=='') {$haystack='no haystack given';}
$needle   = $_POST['needle'];   if ($needle=='')   {$needle='no needle given';}

function rexxpos($h,$n) {
  $pos = strpos($h,$n);
  if ($pos === false) { $pos=-1; }
  else                { $pos=$pos+1; }
  return ($pos);
 }

$pos=rexxpos($haystack,$needle);
$tx1 = ;
if ($pos==-1){ $n=0; }  
else         { $n=1; }  

if ($pos==1){ $tx1=; }
if ($pos==strlen($haystack)-strlen($needle)+1)
            { $tx1=; }

if ($n>0) { 
  $pl=$pos; 
  $p=$pos;  
  $x=;
  $h=$haystack;
  while ($p>0) {
    $h=substr($x,0,$p).substr($h,$p);
    $p=rexxpos($h,$needle);
    if ( $p>0 ) { $n=$n+1; $pl=$pl..$p; }
  }
       if ($n==1) { $txt=; }
  else if ($n==2) { $txt=; }
  else            { $txt=; }
}
else              { $txt=; }
?>
<html>
  <head>
    <title>Character Matching</title>
    <meta name= content=>
    <meta name= content=>
    <style>
      p { font: 120% courier; }
    </style>
  </head>
  <body>
    <p><strong>Haystack:&nbsp;'<?php echo  ?>'</strong></p>
    <p><strong>Needle:&nbsp;&nbsp;&nbsp;'<?php echo  ?>'</strong></p>
    <p><strong><?php echo  ?></strong></p>
    <!-- special message: -->
    <p  style=;><strong><?php echo  ?></strong></p>
  </body>
</html>