gudfry Posted July 21, 2008 Share Posted July 21, 2008 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 Quote Link to comment https://forums.phpfreaks.com/topic/115788-how-can-i-fixed-my-function/ Share on other sites More sharing options...
.josh Posted July 21, 2008 Share Posted July 21, 2008 please use code tags when posting code. Also, you're going to have to be more specific about your problem. Quote Link to comment https://forums.phpfreaks.com/topic/115788-how-can-i-fixed-my-function/#findComment-595243 Share on other sites More sharing options...
gudfry Posted July 21, 2008 Author Share Posted July 21, 2008 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 Quote Link to comment https://forums.phpfreaks.com/topic/115788-how-can-i-fixed-my-function/#findComment-595250 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.