javascript: remove value fom array
2019-12-31
Q; How to remove a value from a javascript array ?
A: use splice
method to cut off value from array
/**
* remove value fom array
*/
Array.prototype.remove = function(mValue) {
return this.splice(this.indexOf(mValue), 1);
}
// example array
var aData = [1, 2, 3, 4, 5];
// usage: remove the value "4"
aData.remove(4);
// gives: [1, 2, 3, 5]
console.log(aData);
[…]
php: read directory
2019-12-29
here are different ways to read a directory with php.
current level
using array_diff & scandir: read /var/www/Foo/
and ignore .dot files
$aContent = array_diff(scandir ('/var/www/Foo/'), array('..', '.', '.htaccess', '.htpasswd'));
using preg_grep & scandir: read /var/www/Foo/
$aContent = […]