$key = 'key2';
uasort($arr, function($a,$b) use($key){
if ($a[$key] == $b[$key]) {
return 0;
}
return ($a[$key] < $b[$key]) ? -1 : 1;
});
//update
/*
@param array $arr array to sort
@param string $key key
@param int $direction 1 or -1
*/
function sortByKey($arr, $key, $direction = 1){
uasort($arr, function($a,$b) use($key, $direction){
if ($a[$key] == $b[$key]) {
return 0;
}
return ($a[$key] < $b[$key]) ? -1*$direction : 1*direction;
});
return $arr
}
array_combine(array_keys($arr1), array_values($arr2));
$a=[
'p'=>[
'r'=>[
'i'=>'pri',
],
]
];
$key=['p', 'r', 'i'];
$_a = $a;
foreach($key as $k){
$_a = $_a[$k];
}
echo($_a);
LEFT JOIN " . DB_PREFIX . "product_description pd ON (p.product_id = pd.product_id)
LEFT JOIN " . DB_PREFIX . "category_description pd ON (p.type_prefix = pd.type_prefix)
...
<head>
<link href="css/common.css" rel="stylesheet">
<?php if($user['color_scheme']): ?>
<link id="themelink" href="css/<?=$user['color_scheme']?>.css" rel="stylesheet">
<?php else: ?>
<link href="css/default.css" rel="stylesheet">
<?php endif; ?>
</head>
...
<input type="radio" value="theme1" name="theme">
<input type="radio" value="theme2" name="theme">
var themelink = $('#themelink')
$('input[name="theme"]').on('change', function(){
var theme = this.value;
themelink.attr('href', 'css/'+theme+'.css');
$.post('/some/server/path',{theme:theme}).then(function(response){
console.log('theme has been changed');
})
});
<form method="post" action="/order">
<input type="hidden" name="memory" value="<?=$_GET['memory']?>"/>
<input type="hidden" name="memory" value="<?=$_GET['color']?>"/>
<input type="submit" value="Submit" />
</form>
if(empty($var)){
// code here...
}elseif(is_numeric($var)){
// another code here...
}else{
// and here
}
if(validate_text($text)){
$text_id_database = $db->select('some query here where text = '.$text);
if($text_in_database){
write_some_info();
}else{
$errors[] = 'some error';
}
}else{
$errors[] = 'Invalid text';
}
.target:hover,
.target:active{
animation: rotate 0.5s ease-in-out;
}
keyframes rotate{
to{
transform:rotate(360deg);
}
}