Jump to content

how can i fixed my function


gudfry

Recommended Posts

hi to all;

 

          How can i fixed my function, where i might got wrong. I have a function that return false if my strpos did not found any much.

 

         processline.php

 

         <?php

function processLine($line)	{

	if(strpos($line,'/* $')===0) {
		// chexk for the ':' 
		if(strpos($line,':')>=5) {
			// check for the ending '*/'
			if (strpos($line,'*/')>=6) { // we have a matching string, so get the values and returnin  array

				$retval=Array();
				$positionOfColon=strpos($line,":");

				echo $positionOfColon;
				$lengthOfString0Ineed=$positionOfColon-4; // or something like that, might miss 1

					$retval[0]=substr($line,5,$lengthOfString0Ineed);
					$retval[1]=substr($line,$positionOfColon+1,strlen($line)-$positionOfColon-3);


				return $retval;
			}
			else { // third condition not met
				return false;

				}
			}
			else { // no match for '/* $' at the beginning of the line
				return false;
		}
	}
}

?>

        $result=processLine('/* $Author: chad */'); return true;

$result=processLine('/* $chad : author */'); return true

        $result=processLine('/*$ :*/'); // boolean false

        $result=processLine('/* $ :');  // boolean false

        $result=processLine('/*$ : '); // boolean false

$result=processLine(' : */); // boolean false

any idea with this??

 

thank

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/115788-how-can-i-fixed-my-function/
Share on other sites

well ist ok. thank for your advice,

 

  Well if its hard to understand, i have an example scenario.  i Have two files in my folder, my main goal is to look for a code on how can i read a multi-comment like this symbol  ( /* $ author : chad */ ) the function that i want to look for is only retuning value which is look like this

                if (strpos(/* $Author : chad */ ) { // print only the Auhtor : Chad

 

                if (strpos(/* $Author  chad */ ) { // should return false

 

                if (strpos(/* $ : chad */ ) { // should return false

             

                if (strpos(/* $Author : */) { //  should return false

                   

                if (strpos(/* $Author : chad ) {  // should return false

                   

                if (strpos(/* $ : */) { // should return false

 

hope this would clear

 

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.