Hi, say i have a string that looks like: //Comment1 // Hey look //Comment2 // Now look How do I get the position number of the end of "//Comment1 //" BTW the length of the string is variable, so I can't count from the start.
<? $string = '//Comment1 // Hey look //Comment2 // Now look'; function strpostend( $haystack, $needle, $offset = null ) { return strpos( $haystack, $needle, $offset ) + strlen( $needle ); } $test1 = 'Comment1 //'; printf('%s ends at offset %d<br />', $test1, strpostend( $string, $test1 ) ); printf('The rest of the string is<br /><pre>%s</pre>', substr( $string, strpostend( $string, $test1 ) ) ); PHP: like that .....
what did you have to modify ?? I musta misunderstood the question, as I understand it returns the position of the end of the string you pass to it ......
Yeah I posted example code, that wasn't exactly how it was in my real code *oops* so it was my fault.