public function assoc_key_values_to_array($ASSOC, $AKEY, $STOPONERROR = true)
    {
        $RETURN = [];

        // Make sure its $ASSOC is an array or it errors out.
        if (is_array($ASSOC)) {
            // Loop through the array of key=>value pairs
            foreach ($ASSOC as $KEY => $VALUE) {
                if (isset($VALUE[$AKEY]) && $VALUE[$AKEY] !== '') {
                    if (isset($VALUE['uuid']) && $VALUE['uuid']) {
                        // If the query returns a UUID, use that as our array key!
                        $RETURN[$VALUE['uuid']] = $VALUE[$AKEY];
                    } else {
                        // If the query does NOT return a UUID, use sequencial keys
                        array_push($RETURN, $VALUE[$AKEY]);
                    }
                } elseif ($STOPONERROR) {
                    throw new \Exception("Assoc array value does not have key {$KEY}");
                }
            }
        }

        return $RETURN;
    }
public function assoc_key_values_to_array($ASSOC, $AKEY, $STOPONERROR = true)
    {
        $RETURN = [];

        // Make sure its $ASSOC is an array or it errors out.
        if (is_array($ASSOC)) {
            // Loop through the array of key=>value pairs
            foreach ($ASSOC as $KEY => $VALUE) {
                if (isset($VALUE[$AKEY]) && $VALUE[$AKEY] !== '') {
                    if (isset($VALUE['uuid']) && $VALUE['uuid']) {
                        // If the query returns a UUID, use that as our array key!
                        $RETURN[$VALUE['uuid']] = $VALUE[$AKEY];
                    } else {
                        // If the query does NOT return a UUID, use sequencial keys
                        array_push($RETURN, $VALUE[$AKEY]);
                    }
                } elseif ($STOPONERROR) {
                    throw new \Exception("Assoc array value does not have key {$KEY}");
                }
            }
        }

        return $RETURN;
    }
public function assoc_key_values_to_array ( $ ASSOC , $ AKEY , $ STOPONERROR = true ) { $ RETURN = [ ] ; // Make sure its $ASSOC is an array or it errors out. if ( is_array ( $ ASSOC ) ) { // Loop through the array of key=>value pairs foreach ( $ ASSOC as $ KEY => $ VALUE ) { if ( isset ( $ VALUE [ $ AKEY ] ) && $ VALUE [ $ AKEY ] !== '' ) { if ( isset ( $ VALUE [ 'uuid' ] ) && $ VALUE [ 'uuid' ] ) { // If the query returns a UUID, use that as our array key! $ RETURN [ $ VALUE [ 'uuid' ] ] = $ VALUE [ $ AKEY ] ; } else { // If the query does NOT return a UUID, use sequencial keys array_push ( $ RETURN , $ VALUE [ $ AKEY ] ) ; } } elseif ( $ STOPONERROR ) { throw new \ Exception ( "Assoc array value does not have key {$KEY}" ) ; } } } return $ RETURN ; }
This converts an array of key=>value pairs into a flat array of one of the keys values
This converts an array of key = > value pairs into a flat array of one of the keys values