Click here to Skip to main content
15,499,011 members
Home / Discussions / Web Development
   

Web Development

 
AnswerRe: Integrate 3rd party Authenticator app Pin
Richard Deeming18-May-21 5:06
mveRichard Deeming18-May-21 5:06 
GeneralRe: Integrate 3rd party Authenticator app Pin
Super Lloyd18-May-21 17:48
MemberSuper Lloyd18-May-21 17:48 
QuestionCSS not showing on my website! HELP! Pin
Gee_Suss 9-May-21 12:27
MemberGee_Suss 9-May-21 12:27 
AnswerRe: CSS not showing on my website! HELP! Pin
SeanChupas11-May-21 4:04
MemberSeanChupas11-May-21 4:04 
QuestionFiltering an array of objects based on (another object/array of objects) Pin
Pavithran R8-May-21 10:07
MemberPavithran R8-May-21 10:07 
AnswerRe: Filtering an array of objects based on (another object/array of objects) Pin
jsc429-May-21 23:33
professionaljsc429-May-21 23:33 
QuestionPHP7, uasort method, return new instance Pin
jkirkerx23-Apr-21 9:12
professionaljkirkerx23-Apr-21 9:12 
AnswerRe: PHP7, uasort method, return new instance [Maybe Solved] Pin
jkirkerx24-Apr-21 10:53
professionaljkirkerx24-Apr-21 10:53 
I ended up with 2 methods that I couldn't figure out yesterday, the other being array_intersect which requires an array and not an object. So after about an hour of research on arrays and objects, I did some converting and ended up with this today, which worked after running several tests.
/*
* Method intersect
* Object Oriented array_intersect
* Using variadic argument
* <a href="https://www.schmengler-se.de/en/2017/04/php-7-type-safe-arrays-of-objects/">https://www.schmengler-se.de/en/2017/04/php-7-type-safe-arrays-of-objects/</a>
*/
public function intersect(KeyValues ...$keyValues): KeyValues {

    $a = iterator_to_array($this->traversable($this->getInnerIterator()));
    $b = iterator_to_array($this->traversable($keyValues));

    $arrayItems = array_intersect($a, $b);

    $newKeyValues = new KeyValues();
    foreach ($arrayItems as $arrayItem) {

        $newKeyValue = new KeyValue();
        $newKeyValue->setKey($arrayItem[0]);
        $newKeyValue->setValue($arrayItem[1]);
        $newKeyValues->add($newKeyValue);
    }

    return $newKeyValues;

}

Which segways to this. I didn't need uasort, and resorted back to sort. I really just want to reference the original object and sort it. So I'm going to have to give this more thought. In other words just sort the getInnerIterator().

Called it like this
$taskKeyValues = $taskKeyValues->sort();
/*
 * Method sort
 * Sort an Object instead of an array
 */
public function sort(): KeyValues {

    $arrayItems = iterator_to_array($this->traversable($this->getInnerIterator()));

    sort($arrayItems);

    $newKeyValues = new KeyValues();
    foreach ($arrayItems as $arrayItem) {

        $newKeyValue = new KeyValue();
        $newKeyValue->setKey($arrayItem[0]);
        $newKeyValue->setValue($arrayItem[1]);
        $newKeyValues->add($newKeyValue);
    }

    return $newKeyValues;

}
If it ain't broke don't fix it
Discover my world at jkirkerx.com

Questionsearch word in code phpstorm Pin
sookitak18-Apr-21 5:06
Membersookitak18-Apr-21 5:06 
AnswerRe: search word in code phpstorm Pin
SeanChupas23-Apr-21 10:16
MemberSeanChupas23-Apr-21 10:16 
QuestionMaster Detail CRUD using blazor Pin
sanket16413-Apr-21 21:52
Membersanket16413-Apr-21 21:52 
SuggestionRe: Master Detail CRUD using blazor Pin
Shaun C Curtis14-Apr-21 7:37
mvaShaun C Curtis14-Apr-21 7:37 
GeneralRe: Master Detail CRUD using blazor Pin
sanket16414-Apr-21 9:40
Membersanket16414-Apr-21 9:40 
AnswerRe: Master Detail CRUD using blazor Pin
Mycroft Holmes14-Apr-21 14:28
professionalMycroft Holmes14-Apr-21 14:28 
GeneralRe: Master Detail CRUD using blazor Pin
sanket16415-Apr-21 9:09
Membersanket16415-Apr-21 9:09 
GeneralRe: Master Detail CRUD using blazor Pin
Mycroft Holmes15-Apr-21 14:52
professionalMycroft Holmes15-Apr-21 14:52 
QuestionDo events like slider and drag and drop need to be well known? Pin
Oyee 202129-Mar-21 20:31
MemberOyee 202129-Mar-21 20:31 
AnswerModeration Pin
Nelek29-Mar-21 20:32
protectorNelek29-Mar-21 20:32 
AnswerRe: Do events like slider and drag and drop need to be well known? Pin
Richard Deeming29-Mar-21 22:42
mveRichard Deeming29-Mar-21 22:42 
QuestionHTML Rotate results in messed up and unresponsive design. Pin
Resource Link26-Mar-21 8:19
MemberResource Link26-Mar-21 8:19 
QuestionRefresh token API development and documentation Pin
kyclk1125-Mar-21 20:15
Memberkyclk1125-Mar-21 20:15 
QuestionPHP7, how to create a json array of keyvalues from an object Pin
jkirkerx25-Mar-21 11:57
professionaljkirkerx25-Mar-21 11:57 
AnswerRe: PHP7, how to create a json array of keyvalues from an object Pin
jkirkerx26-Mar-21 12:18
professionaljkirkerx26-Mar-21 12:18 
QuestionHi, can someone help me with file-upload feature for my Angular app? Pin
kyclk1117-Mar-21 4:41
Memberkyclk1117-Mar-21 4:41 
AnswerRe: Hi, can someone help me with file-upload feature for my Angular app? Pin
jkirkerx25-Mar-21 12:02
professionaljkirkerx25-Mar-21 12:02 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.