UNPKG

phpjs

Version:

php.js offers community built php functions in javascript

74 lines (55 loc) 2 kB
<!-- Generated by Rakefile:build --> <strong> faq </strong> on 2010-08-02 00:39:49 <br /> @aleczapka: please read the first entry in the FAQ ( http://wiki.github.com/kvz/phpjs/faq ) <hr /> <strong> aleczapka </strong> on 2010-08-02 00:32:01 <br /> I don't get it.. what's wrong with native javascript function array.pop() ? <hr /> <strong> <a href="http://kevin.vanzonneveld.net" rel="nofollow">Kevin van Zonneveld</a> </strong> on 2009-02-02 23:33:48 <br /> @ Brett Zamir: I missed that, I'll look into it. <hr /> <strong> <a href="http://bahai-library.com" rel="nofollow">Brett Zamir</a> </strong> on 2009-02-02 11:46:49 <br /> The harder part of fixing these functions goes beyond making them work with arrays and objects; if you really want them to be faithful to PHP, they need to force numerical indexes to start over at 0 (e.g., if you have an object which has numerical indexes starting at 5 or skipping around, etc.) as soon as these functions are used. I think we can use an inner function I developed for array_splice() to help with that. <hr /> <strong> <a href="http://kevin.vanzonneveld.net" rel="nofollow">Kevin van Zonneveld</a> </strong> on 2008-05-31 12:38:39 <br /> @ delete key in array: I'm not sure array_deletekey is a valid PHP functions ;) But in PHP, why don't you use unset() ? <hr /> <strong> delete key in array (not available in php!) </strong> on 2008-05-27 16:22:45 <br /> The code beneath deletes the instance with key &amp;quot;todelete&amp;quot; in an array, in any position in the array(!). Even PHP doesn't have an function to accomplish this. Alex Pot Zinrijk Webtechniek http://www.zinrijk.nl/webapplicaties Haarlem, the Netherlands <pre><code>function array_deletekey( mixed_var, todelete) { last=mixed_var.length; narr=new Array(); correction=0; for (x=0;x&amp;lt;last;x++) { if(mixed_var[x]!=todelete)narr[x-correction]=mixed_var[x]; else correction++; } mixed_var=narr; return mixed_var; }</code></pre> <hr />