UNPKG

phpjs

Version:

php.js offers community built php functions in javascript

91 lines (69 loc) 2.22 kB
<!-- Generated by Rakefile:build --> <strong> <a href="http://kevin.vanzonneveld.net" rel="nofollow">Kevin van Zonneveld</a> </strong> on 2008-03-05 23:17:06 <br /> @ Alfonso Jiménez: Oh I should have seen that.. Anyway, I've updated the function and the test page gives the correct results now: http://kevin.vanzonneveld.net/pj_tester.php thanks again! <hr /> <strong> Alfonso Jiménez </strong> on 2008-03-05 21:23:09 <br /> Arggg I made an error in the last example! It's &amp;quot;is&amp;quot; instead of &amp;quot;mi&amp;quot; :) If you realize &amp;quot;mi&amp;quot; is not in the string &amp;quot;This is a Simple text&amp;quot;. I'll try to develop another contribution soon :) Regards! <hr /> <strong> <a href="http://kevin.vanzonneveld.net" rel="nofollow">Kevin van Zonneveld</a> </strong> on 2008-03-05 17:25:15 <br /> @ Alfonso Jiménez: Hi Alfonso, thanks for your second contribution &amp;amp; the example! Only one thing, the example produces: false instead of: 'is is a Simple text.' Maybe you can see what's going wrong? (btw, I had to add the '{' &amp;amp; '}' to make it compatible with the packer) <hr /> <strong> Alfonso Jiménez </strong> on 2008-03-05 09:49:22 <br /> BTW, Usage example: <pre><code>strpbrk('This is a Simple text', 'mi')</code></pre> Regards! Alfonso Jiménez (http://www.alfonsojimenez.com) <hr /> <strong> Alfonso Jiménez </strong> on 2008-03-05 09:45:56 <br /> Hey Kevin. My second contribution is here :) <pre><code> function strpbrk(haystack, char_list) { var lon = haystack.length; var lon_search = char_list.length; var ret = false; var stack = ''; if(lon &amp;gt;= lon_search) { if(lon == lon_search) { if(haystack == char_list) ret = haystack; } else { j = 0; i = 0; while(i &amp;lt; lon_search &amp;amp;&amp;amp; j &amp;lt; lon &amp;amp;&amp;amp; !ret) { if(char_list[i] == haystack[j]) { i++; if(i == lon_search) ret = true; } j++; } if(ret) for(i = (j-lon_search); i &amp;lt; lon; i++) stack += haystack[i]; if(stack != '') ret = stack; } } return ret; }</code></pre> Re <hr />