PHPKonf Istanbul PHP Conference 2019 - Call for Papers


Please answer this simple SPAM challenge: four minus three?
(Example: nine)

The Note You're Voting On

shooo dot xz at gmail dot com
5 years ago
Hi, i've worked a abit on reference stuff.
Here is what i've noticed.

The problem: Sort mysql result through columns

$rewrite_self = gt::recombine(array('lang', 'id'), 'value_column', $sql_result);

public static function recombine($keys, $value, &$arr) {
        $ref = array();
        $main = &$ref;
        foreach($arr as $data) {
            foreach($keys as $key) {
                if (!is_array($ref[$data[$key]])) $ref[$data[$key]] = array();
                $ref = &$ref[$data[$key]];
            $ref = $data[$value];
            $ref = &$main;
        return $main;

array(2) {
  array(2) {
    string(4) "value_column_str"
    string(4) "value_column_str2"
  array(1) {
    string(7) "value_column_str3"


<< Back to user notes page

To Top