note 115003 deleted from function.implode by peehaa
| From: | peehaa@php.net | Date: | Sun, 28 Apr 2019 10:49:09 +0000 |
| Subject: | note 115003 deleted from function.implode by peehaa | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-210815@lists.php.net to get a copy of this message | ||
Note Submitter: cottton at i-stats dot net
----
in case you want to implode by keys:
<?php
const POSITION_KEY = 0;
const POSITION_VAL = 2;
const POSITION_DESC = 1;
$key = 'key';
$val = 'val';
$desc = 'desc';
$arr = array(
POSITION_KEY => $key,
POSITION_VAL => $val,
POSITION_DESC => $desc,
);
echo kimplode('=',$arr); // key=desc=val
echo '<br>';
echo krimplode('=',$arr); // val=desc=key
function kimplode($glue,$arr){
ksort($arr);
return implode($glue,$arr);
}
function krimplode($glue,$arr){
krsort($arr);
return implode($glue,$arr);
}
?>