php: Sort a multidimensional array by value
2020-01-18
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',
)
);
[…]
JavaScript: how to add CSS style tag with settings to DOM
2020-01-13
Native JS
oStyleAppend = function (content) {
oStyle = document.createElement('STYLE');
oStyle.type = 'text/css';
oStyle.appendChild(document.createTextNode(content));
document.head.appendChild(oStyle);
}
oStyleAppend('.example {height: 100px;}');
jquery
$('<style>').text('.example {height: 100px;}').appendTo(document.head);
[…]