FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » PHP manual note
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
PHP manual note [message #169880] Wed, 29 September 2010 08:34
jrobinss is currently offline  jrobinss
Messages: 3
Registered: September 2010
Karma:
Junior Member
Hi all,

I've posted a new note on the manual page:
http://www.php.net/manual/en/function.strpos.php

It never appeared. Does anyone have a hint as to what didn't work out?
I'm wondering whether it's more likely to be...
* because the note was useless or badly formulated
* because the validation of new notes is done rarely
* for some other reason.
My only motivation was to be useful to others, so it's really not
dramatic that it didn't appear. It's just intriguing.

For what it's worth, here's the gist of the message, an alternative,
recursive, version of the "function for counting the number of
occurrences of the needle into the stack" (note by Nikolay Christov).
I find it more elegant, but YMMV.

/**
* Computes the number of times a string is found in another one.
* Never returns false or true or null, returns a number.
*/
function strinpos($haystack, $needle, $offset = 0) {
$pos = stripos($haystack, $needle, $offset);
if ($pos === false) { // end recursion test
return 0;
}
return 1 + strinpos($haystack, $needle, $pos + 1);
}


// example call (untested, typed directly here for the newsgroup post)
$numberOfOccurences = strinpos("it is a long long way", "long"); //
returns 2
[Message index]
 
Read Message
Previous Topic: global var vs session vs something else maybe?
Next Topic: why does in_array return true
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Fri Sep 20 20:21:52 GMT 2024

Total time taken to generate the page: 0.04576 seconds