Jump to content

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

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.