How to dynamically load Cascading Style Sheet (CSS) and JS sources within Javascript
2020-01-22 2020-01-26 10:43:45
Loading JavaScript
simple
var oScript = document.createElement('script');
oScript.src = 'URL';
document.head.appendChild(oScript);
with callback
var oScript = document.createElement('script');
oScript.onload = function () {
// ...code...
};
oScript.src = 'URL';
document.head.appendChild(oScript);
Loading CSS
var oLink = document.createElement('link');
oLink.id = cssId;
oLink.rel = 'stylesheet';
oLink.type = 'text/css';
[…]
php: Sort a multidimensional array by value
2020-01-18 2020-01-18 11:48:07
say you want to sort the following array by the value of mainType
.
array $aData
$aData = array(
0 => array(
'name' => 'abc',
'size' => 7000,
'type' => 'image/png',
'mainType' => 'image',
),
1 => array(
'name' => 'document',
'size' => 25000,
'type' => 'application/pdf',
'mainType' => 'application',
)
);
sort method
using php's usort
command here will do the job.
[…]