UNPKG

phpjs

Version:

php.js offers community built php functions in javascript

74 lines (62 loc) 1.88 kB
<!-- Generated by Rakefile:build --> <strong> <a href="http://kevin.vanzonneveld.net" rel="nofollow">Kevin van Zonneveld</a> </strong> on 2008-10-06 12:08:20 <br /> @ Onno Marsman: Processed. Thank you! <hr /> <strong> Onno Marsman </strong> on 2008-10-04 17:41:10 <br /> Improved to accept things other than strings. Also &amp;quot;if(f_offset == undefined) {&amp;quot; seemed useless since indexOf accepts undefined as a 0 anyway. Also changed &amp;gt; -1 to !== -1, to increase performance a tiny bit. <pre><code> function stripos ( f_haystack, f_needle, f_offset ) { var haystack = (f_haystack+'').toLowerCase(); var needle = (f_needle+'').toLowerCase(); var index = 0; if ((index = haystack.indexOf(needle, f_offset)) !== -1) { return index; } return false; } </code></pre> <hr /> <strong> <a href="http://kevin.vanzonneveld.net" rel="nofollow">Kevin van Zonneveld</a> </strong> on 2008-03-07 19:29:30 <br /> @ Thiago Mata: Thanks alot, I've added the function! <hr /> <strong> call_user_func_array </strong> on 2008-03-07 15:15:15 <br /> <pre><code> /** * @author Thiago Mata * @date 07/03/2008 * @param callback strFunctionName * @param array arrParam * @return mixer * @url thiagomata.blog.com */ function call_user_func_array( strFunctionName , arrParam ) { var strCommand = &amp;quot;&amp;quot;; var i; strCommand += &amp;quot;return &amp;quot; + strFunctionName + &amp;quot;(&amp;quot;; for( i = 0; i &amp;lt; arrParam.length; ++i ) { strCommand += &amp;quot;arrParam[&amp;quot; + i + &amp;quot;]&amp;quot; ; if( ( i + 1 ) != arrParam.length ) { strCommand += &amp;quot;,&amp;quot;; } } strCommand += &amp;quot;)&amp;quot;; var oFunction = new Function( &amp;quot;arrParam&amp;quot; , strCommand ); return oFunction( arrParam ); } </code></pre> <hr />