gudfry Posted July 16, 2008 Share Posted July 16, 2008 hello to all; I' have litle problem with some php stuff, I had created a function for strpos, substr, strlen which inserted to the turnword.php. here some of my code. 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) { $retval=Array(); $positionOfColon=strpos($line,":"); $lengthOfString0Ineed=$positionOfColon-4; $retval[0]=substr($line,4,$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; } } } ?> the code above well insert into turnword.php to read the multi-comment line. turnword.php <?php require_once('processline.php'); /* $Author : Chad */ this will return Author : Chad /* Author : chad */ this will return false /* $chad : Author */ this will retun chad : Author. /* $ : Chad */ this will return false. /* : Chad /* this will retun false. /* $Author : */ this will return false. /* $chad : */ this will return false. // this function will return a whole string to reverse. function turnwords($string) { // below $result=strrev($string); // above return $result; } $result=turnwords('DEF'); echo '<p>'.($result).'</p>'; ?> hope you have idea with this. :?: :?: Link to comment https://forums.phpfreaks.com/topic/114958-strpos-strlen-substr-problem-pls-help-me/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.