Jump to content

=== && ==


desithugg

Recommended Posts

Hi, I'm trying to convert a function someone wrote for me in PHP a while back which returns the text between two objects in an array.

For example.

text="[saad]hello[/saad]sffsad90aa89a8da[saad]bye[/saad]";
found=findText("[saad]","[/saad]",text);
//found[0] would return hello
//found[1] would return bye

Below is what I've wrote, but it doesn't seem to be working. I believe the problem is the !==, anybody else have a clue?

function mySubStr(strP,startP,endP){
   if(endP==0)
      endP=strP.length-startP;
   return strP.substr(startP,endP);
}
function myIndexOf(strP,searchP){
   return strP.indexOf(searchP);
}
function findText(openPin,endPin,hayStack){
   var textFound = new Array();
   openPin  = openPin.toLowerCase();
   endPin   = endPin.toLowerCase();
   var opLength = opLength.length;
   var epLength = epLength.length;
   var hsCheck  = hsCheck.toLowerCase();
   do{
      opPos=myIndexOf(hsCheck,openPin);
      if(opPos!==false){
         epPos=myIndexOf(mySubStr(hsCheck,opPos+opLength,0),endP);
         if(epPos!==false){
            textFound[] = mySubStr(hayStack,opPos+opLength,epPos);
            hayStack    = mySubStr(hayStack,opPos+opLength+epPos+epLength,0);
            hsCheck     = hayStack.toLowerCase();
         }
      }
   }while((opPos!==false) && (epPos!==false));
   return textFound;
}

Link to comment
https://forums.phpfreaks.com/topic/119881--/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.