How can I push my array that contains a specific value to the last position?












0















This is my array, and I would like that username is always at the beginning and password is always at the end.



  array(5) {
[0]=>
array(8) {
["fieldName"]=>
string(5) "email"
["type"]=>
string(6) "string"
["scale"]=>
int(0)
["length"]=>
int(191)
["unique"]=>
bool(true)
["nullable"]=>
bool(false)
["precision"]=>
int(0)
["columnName"]=>
string(5) "email"
}
[1]=>
array(8) {
["fieldName"]=>
string(8) "isActive"
["type"]=>
string(7) "boolean"
["scale"]=>
int(0)
["length"]=>
NULL
["unique"]=>
bool(false)
["nullable"]=>
bool(false)
["precision"]=>
int(0)
["columnName"]=>
string(9) "is_active"
}
[2]=>
array(8) {
["fieldName"]=>
string(8) "password"
["type"]=>
string(6) "string"
["scale"]=>
int(0)
["length"]=>
int(64)
["unique"]=>
bool(false)
["nullable"]=>
bool(false)
["precision"]=>
int(0)
["columnName"]=>
string(8) "password"
}
[3]=>
array(8) {
["fieldName"]=>
string(8) "username"
["type"]=>
string(6) "string"
["scale"]=>
int(0)
["length"]=>
int(25)
["unique"]=>
bool(true)
["nullable"]=>
bool(false)
["precision"]=>
int(0)
["columnName"]=>
string(8) "username"
}
[4]=>
array(9) {
["fieldName"]=>
string(2) "id"
["type"]=>
string(7) "integer"
["scale"]=>
int(0)
["length"]=>
NULL
["unique"]=>
bool(false)
["nullable"]=>
bool(false)
["precision"]=>
int(0)
["id"]=>
bool(true)
["columnName"]=>
string(2) "id"
}
}


I could get the array that contains the fieldname password to the end with this code:



$item = $myArray[2];
unset($myArray[2]);
array_push($myArray, $item);


But this is actually not what I am looking for. Because password is not always key 2










share|improve this question

























  • Add tag for the programming language you're using.

    – Pedro Lima
    Nov 23 '18 at 10:43











  • ah ok, it is php

    – Jarla
    Nov 23 '18 at 10:50











  • Can you post the array as var_export or json_encode? That will be much easier to work with

    – Andreas
    Nov 23 '18 at 11:08
















0















This is my array, and I would like that username is always at the beginning and password is always at the end.



  array(5) {
[0]=>
array(8) {
["fieldName"]=>
string(5) "email"
["type"]=>
string(6) "string"
["scale"]=>
int(0)
["length"]=>
int(191)
["unique"]=>
bool(true)
["nullable"]=>
bool(false)
["precision"]=>
int(0)
["columnName"]=>
string(5) "email"
}
[1]=>
array(8) {
["fieldName"]=>
string(8) "isActive"
["type"]=>
string(7) "boolean"
["scale"]=>
int(0)
["length"]=>
NULL
["unique"]=>
bool(false)
["nullable"]=>
bool(false)
["precision"]=>
int(0)
["columnName"]=>
string(9) "is_active"
}
[2]=>
array(8) {
["fieldName"]=>
string(8) "password"
["type"]=>
string(6) "string"
["scale"]=>
int(0)
["length"]=>
int(64)
["unique"]=>
bool(false)
["nullable"]=>
bool(false)
["precision"]=>
int(0)
["columnName"]=>
string(8) "password"
}
[3]=>
array(8) {
["fieldName"]=>
string(8) "username"
["type"]=>
string(6) "string"
["scale"]=>
int(0)
["length"]=>
int(25)
["unique"]=>
bool(true)
["nullable"]=>
bool(false)
["precision"]=>
int(0)
["columnName"]=>
string(8) "username"
}
[4]=>
array(9) {
["fieldName"]=>
string(2) "id"
["type"]=>
string(7) "integer"
["scale"]=>
int(0)
["length"]=>
NULL
["unique"]=>
bool(false)
["nullable"]=>
bool(false)
["precision"]=>
int(0)
["id"]=>
bool(true)
["columnName"]=>
string(2) "id"
}
}


I could get the array that contains the fieldname password to the end with this code:



$item = $myArray[2];
unset($myArray[2]);
array_push($myArray, $item);


But this is actually not what I am looking for. Because password is not always key 2










share|improve this question

























  • Add tag for the programming language you're using.

    – Pedro Lima
    Nov 23 '18 at 10:43











  • ah ok, it is php

    – Jarla
    Nov 23 '18 at 10:50











  • Can you post the array as var_export or json_encode? That will be much easier to work with

    – Andreas
    Nov 23 '18 at 11:08














0












0








0








This is my array, and I would like that username is always at the beginning and password is always at the end.



  array(5) {
[0]=>
array(8) {
["fieldName"]=>
string(5) "email"
["type"]=>
string(6) "string"
["scale"]=>
int(0)
["length"]=>
int(191)
["unique"]=>
bool(true)
["nullable"]=>
bool(false)
["precision"]=>
int(0)
["columnName"]=>
string(5) "email"
}
[1]=>
array(8) {
["fieldName"]=>
string(8) "isActive"
["type"]=>
string(7) "boolean"
["scale"]=>
int(0)
["length"]=>
NULL
["unique"]=>
bool(false)
["nullable"]=>
bool(false)
["precision"]=>
int(0)
["columnName"]=>
string(9) "is_active"
}
[2]=>
array(8) {
["fieldName"]=>
string(8) "password"
["type"]=>
string(6) "string"
["scale"]=>
int(0)
["length"]=>
int(64)
["unique"]=>
bool(false)
["nullable"]=>
bool(false)
["precision"]=>
int(0)
["columnName"]=>
string(8) "password"
}
[3]=>
array(8) {
["fieldName"]=>
string(8) "username"
["type"]=>
string(6) "string"
["scale"]=>
int(0)
["length"]=>
int(25)
["unique"]=>
bool(true)
["nullable"]=>
bool(false)
["precision"]=>
int(0)
["columnName"]=>
string(8) "username"
}
[4]=>
array(9) {
["fieldName"]=>
string(2) "id"
["type"]=>
string(7) "integer"
["scale"]=>
int(0)
["length"]=>
NULL
["unique"]=>
bool(false)
["nullable"]=>
bool(false)
["precision"]=>
int(0)
["id"]=>
bool(true)
["columnName"]=>
string(2) "id"
}
}


I could get the array that contains the fieldname password to the end with this code:



$item = $myArray[2];
unset($myArray[2]);
array_push($myArray, $item);


But this is actually not what I am looking for. Because password is not always key 2










share|improve this question
















This is my array, and I would like that username is always at the beginning and password is always at the end.



  array(5) {
[0]=>
array(8) {
["fieldName"]=>
string(5) "email"
["type"]=>
string(6) "string"
["scale"]=>
int(0)
["length"]=>
int(191)
["unique"]=>
bool(true)
["nullable"]=>
bool(false)
["precision"]=>
int(0)
["columnName"]=>
string(5) "email"
}
[1]=>
array(8) {
["fieldName"]=>
string(8) "isActive"
["type"]=>
string(7) "boolean"
["scale"]=>
int(0)
["length"]=>
NULL
["unique"]=>
bool(false)
["nullable"]=>
bool(false)
["precision"]=>
int(0)
["columnName"]=>
string(9) "is_active"
}
[2]=>
array(8) {
["fieldName"]=>
string(8) "password"
["type"]=>
string(6) "string"
["scale"]=>
int(0)
["length"]=>
int(64)
["unique"]=>
bool(false)
["nullable"]=>
bool(false)
["precision"]=>
int(0)
["columnName"]=>
string(8) "password"
}
[3]=>
array(8) {
["fieldName"]=>
string(8) "username"
["type"]=>
string(6) "string"
["scale"]=>
int(0)
["length"]=>
int(25)
["unique"]=>
bool(true)
["nullable"]=>
bool(false)
["precision"]=>
int(0)
["columnName"]=>
string(8) "username"
}
[4]=>
array(9) {
["fieldName"]=>
string(2) "id"
["type"]=>
string(7) "integer"
["scale"]=>
int(0)
["length"]=>
NULL
["unique"]=>
bool(false)
["nullable"]=>
bool(false)
["precision"]=>
int(0)
["id"]=>
bool(true)
["columnName"]=>
string(2) "id"
}
}


I could get the array that contains the fieldname password to the end with this code:



$item = $myArray[2];
unset($myArray[2]);
array_push($myArray, $item);


But this is actually not what I am looking for. Because password is not always key 2







php arrays sorting






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 23 '18 at 10:50







Jarla

















asked Nov 23 '18 at 10:28









JarlaJarla

2,32311639




2,32311639













  • Add tag for the programming language you're using.

    – Pedro Lima
    Nov 23 '18 at 10:43











  • ah ok, it is php

    – Jarla
    Nov 23 '18 at 10:50











  • Can you post the array as var_export or json_encode? That will be much easier to work with

    – Andreas
    Nov 23 '18 at 11:08



















  • Add tag for the programming language you're using.

    – Pedro Lima
    Nov 23 '18 at 10:43











  • ah ok, it is php

    – Jarla
    Nov 23 '18 at 10:50











  • Can you post the array as var_export or json_encode? That will be much easier to work with

    – Andreas
    Nov 23 '18 at 11:08

















Add tag for the programming language you're using.

– Pedro Lima
Nov 23 '18 at 10:43





Add tag for the programming language you're using.

– Pedro Lima
Nov 23 '18 at 10:43













ah ok, it is php

– Jarla
Nov 23 '18 at 10:50





ah ok, it is php

– Jarla
Nov 23 '18 at 10:50













Can you post the array as var_export or json_encode? That will be much easier to work with

– Andreas
Nov 23 '18 at 11:08





Can you post the array as var_export or json_encode? That will be much easier to work with

– Andreas
Nov 23 '18 at 11:08












2 Answers
2






active

oldest

votes


















2














This usort will do what you want. It uses a custom sort function that sorts username to the top and password to the bottom of the list. All other values will generally end up in the same order they started in, although that may be unpredictable.



usort($data, function ($a, $b) {  if ($a['fieldName'] == 'username' || $b['fieldName'] == 'password') return -1;
elseif ($a['fieldName'] == 'password' || $b['fieldName'] == 'username') return 1;
else return 0;
});


I made small demo on 3v4l.org with only a couple of values from each entry; for that the output result is



Array
(
[0] => Array
(
[fieldName] => username
[type] => string
)
[1] => Array
(
[fieldName] => email
[type] => string
)
[2] => Array
(
[fieldName] => isActive
[type] => boolean
)
[3] => Array
(
[fieldName] => id
[type] => integer
)
[4] => Array
(
[fieldName] => password
[type] => string
)
)





share|improve this answer
























  • Thank you, it is working! Can you explain a little bit, because I don't understand why it is actually working. Why is password one time "$a" and ather time "$b"

    – Jarla
    Nov 23 '18 at 14:12






  • 1





    @Jarla When you are sorting using a custom function like this you don't know whether a value will appear in the $a or the $b variable, it just depends on the order in which the sort processes entries in the array. So you have to allow for 'password' to be in $a or in $b. The result changes depending on which variable it is in (because the sort function returns -1 if $a < $b and 1 if $a > $b) so if it is in $a you want it to sort later than the other value the array (so return 1), while if it is in $b we want the other value to sort earlier so return -1. I hope this helps.

    – Nick
    Nov 23 '18 at 23:50



















2














I haven't tested this since I don't want to manually retype your array to real code.



The code uses array_column to make a flat array of fieldname and searches for "password".

If it's found it adds a copy of it last in the array and removes the original then does array_values to reindex the array.



$fieldname = array_column($arr, "fieldName");
$password = array_search("password", $fieldname);
$username = array_search("username", $fieldname);


if($password !== false){
$arr = $arr[$password];
unset($arr[$password]);
}
if($username!== false){
array_unshift($arr, $arr[$username]);
unset($arr[$username]);
}
$arr = array_values($arr);


var_export($arr);





share|improve this answer

























    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53444943%2fhow-can-i-push-my-array-that-contains-a-specific-value-to-the-last-position%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    2














    This usort will do what you want. It uses a custom sort function that sorts username to the top and password to the bottom of the list. All other values will generally end up in the same order they started in, although that may be unpredictable.



    usort($data, function ($a, $b) {  if ($a['fieldName'] == 'username' || $b['fieldName'] == 'password') return -1;
    elseif ($a['fieldName'] == 'password' || $b['fieldName'] == 'username') return 1;
    else return 0;
    });


    I made small demo on 3v4l.org with only a couple of values from each entry; for that the output result is



    Array
    (
    [0] => Array
    (
    [fieldName] => username
    [type] => string
    )
    [1] => Array
    (
    [fieldName] => email
    [type] => string
    )
    [2] => Array
    (
    [fieldName] => isActive
    [type] => boolean
    )
    [3] => Array
    (
    [fieldName] => id
    [type] => integer
    )
    [4] => Array
    (
    [fieldName] => password
    [type] => string
    )
    )





    share|improve this answer
























    • Thank you, it is working! Can you explain a little bit, because I don't understand why it is actually working. Why is password one time "$a" and ather time "$b"

      – Jarla
      Nov 23 '18 at 14:12






    • 1





      @Jarla When you are sorting using a custom function like this you don't know whether a value will appear in the $a or the $b variable, it just depends on the order in which the sort processes entries in the array. So you have to allow for 'password' to be in $a or in $b. The result changes depending on which variable it is in (because the sort function returns -1 if $a < $b and 1 if $a > $b) so if it is in $a you want it to sort later than the other value the array (so return 1), while if it is in $b we want the other value to sort earlier so return -1. I hope this helps.

      – Nick
      Nov 23 '18 at 23:50
















    2














    This usort will do what you want. It uses a custom sort function that sorts username to the top and password to the bottom of the list. All other values will generally end up in the same order they started in, although that may be unpredictable.



    usort($data, function ($a, $b) {  if ($a['fieldName'] == 'username' || $b['fieldName'] == 'password') return -1;
    elseif ($a['fieldName'] == 'password' || $b['fieldName'] == 'username') return 1;
    else return 0;
    });


    I made small demo on 3v4l.org with only a couple of values from each entry; for that the output result is



    Array
    (
    [0] => Array
    (
    [fieldName] => username
    [type] => string
    )
    [1] => Array
    (
    [fieldName] => email
    [type] => string
    )
    [2] => Array
    (
    [fieldName] => isActive
    [type] => boolean
    )
    [3] => Array
    (
    [fieldName] => id
    [type] => integer
    )
    [4] => Array
    (
    [fieldName] => password
    [type] => string
    )
    )





    share|improve this answer
























    • Thank you, it is working! Can you explain a little bit, because I don't understand why it is actually working. Why is password one time "$a" and ather time "$b"

      – Jarla
      Nov 23 '18 at 14:12






    • 1





      @Jarla When you are sorting using a custom function like this you don't know whether a value will appear in the $a or the $b variable, it just depends on the order in which the sort processes entries in the array. So you have to allow for 'password' to be in $a or in $b. The result changes depending on which variable it is in (because the sort function returns -1 if $a < $b and 1 if $a > $b) so if it is in $a you want it to sort later than the other value the array (so return 1), while if it is in $b we want the other value to sort earlier so return -1. I hope this helps.

      – Nick
      Nov 23 '18 at 23:50














    2












    2








    2







    This usort will do what you want. It uses a custom sort function that sorts username to the top and password to the bottom of the list. All other values will generally end up in the same order they started in, although that may be unpredictable.



    usort($data, function ($a, $b) {  if ($a['fieldName'] == 'username' || $b['fieldName'] == 'password') return -1;
    elseif ($a['fieldName'] == 'password' || $b['fieldName'] == 'username') return 1;
    else return 0;
    });


    I made small demo on 3v4l.org with only a couple of values from each entry; for that the output result is



    Array
    (
    [0] => Array
    (
    [fieldName] => username
    [type] => string
    )
    [1] => Array
    (
    [fieldName] => email
    [type] => string
    )
    [2] => Array
    (
    [fieldName] => isActive
    [type] => boolean
    )
    [3] => Array
    (
    [fieldName] => id
    [type] => integer
    )
    [4] => Array
    (
    [fieldName] => password
    [type] => string
    )
    )





    share|improve this answer













    This usort will do what you want. It uses a custom sort function that sorts username to the top and password to the bottom of the list. All other values will generally end up in the same order they started in, although that may be unpredictable.



    usort($data, function ($a, $b) {  if ($a['fieldName'] == 'username' || $b['fieldName'] == 'password') return -1;
    elseif ($a['fieldName'] == 'password' || $b['fieldName'] == 'username') return 1;
    else return 0;
    });


    I made small demo on 3v4l.org with only a couple of values from each entry; for that the output result is



    Array
    (
    [0] => Array
    (
    [fieldName] => username
    [type] => string
    )
    [1] => Array
    (
    [fieldName] => email
    [type] => string
    )
    [2] => Array
    (
    [fieldName] => isActive
    [type] => boolean
    )
    [3] => Array
    (
    [fieldName] => id
    [type] => integer
    )
    [4] => Array
    (
    [fieldName] => password
    [type] => string
    )
    )






    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Nov 23 '18 at 11:19









    NickNick

    27.9k121941




    27.9k121941













    • Thank you, it is working! Can you explain a little bit, because I don't understand why it is actually working. Why is password one time "$a" and ather time "$b"

      – Jarla
      Nov 23 '18 at 14:12






    • 1





      @Jarla When you are sorting using a custom function like this you don't know whether a value will appear in the $a or the $b variable, it just depends on the order in which the sort processes entries in the array. So you have to allow for 'password' to be in $a or in $b. The result changes depending on which variable it is in (because the sort function returns -1 if $a < $b and 1 if $a > $b) so if it is in $a you want it to sort later than the other value the array (so return 1), while if it is in $b we want the other value to sort earlier so return -1. I hope this helps.

      – Nick
      Nov 23 '18 at 23:50



















    • Thank you, it is working! Can you explain a little bit, because I don't understand why it is actually working. Why is password one time "$a" and ather time "$b"

      – Jarla
      Nov 23 '18 at 14:12






    • 1





      @Jarla When you are sorting using a custom function like this you don't know whether a value will appear in the $a or the $b variable, it just depends on the order in which the sort processes entries in the array. So you have to allow for 'password' to be in $a or in $b. The result changes depending on which variable it is in (because the sort function returns -1 if $a < $b and 1 if $a > $b) so if it is in $a you want it to sort later than the other value the array (so return 1), while if it is in $b we want the other value to sort earlier so return -1. I hope this helps.

      – Nick
      Nov 23 '18 at 23:50

















    Thank you, it is working! Can you explain a little bit, because I don't understand why it is actually working. Why is password one time "$a" and ather time "$b"

    – Jarla
    Nov 23 '18 at 14:12





    Thank you, it is working! Can you explain a little bit, because I don't understand why it is actually working. Why is password one time "$a" and ather time "$b"

    – Jarla
    Nov 23 '18 at 14:12




    1




    1





    @Jarla When you are sorting using a custom function like this you don't know whether a value will appear in the $a or the $b variable, it just depends on the order in which the sort processes entries in the array. So you have to allow for 'password' to be in $a or in $b. The result changes depending on which variable it is in (because the sort function returns -1 if $a < $b and 1 if $a > $b) so if it is in $a you want it to sort later than the other value the array (so return 1), while if it is in $b we want the other value to sort earlier so return -1. I hope this helps.

    – Nick
    Nov 23 '18 at 23:50





    @Jarla When you are sorting using a custom function like this you don't know whether a value will appear in the $a or the $b variable, it just depends on the order in which the sort processes entries in the array. So you have to allow for 'password' to be in $a or in $b. The result changes depending on which variable it is in (because the sort function returns -1 if $a < $b and 1 if $a > $b) so if it is in $a you want it to sort later than the other value the array (so return 1), while if it is in $b we want the other value to sort earlier so return -1. I hope this helps.

    – Nick
    Nov 23 '18 at 23:50













    2














    I haven't tested this since I don't want to manually retype your array to real code.



    The code uses array_column to make a flat array of fieldname and searches for "password".

    If it's found it adds a copy of it last in the array and removes the original then does array_values to reindex the array.



    $fieldname = array_column($arr, "fieldName");
    $password = array_search("password", $fieldname);
    $username = array_search("username", $fieldname);


    if($password !== false){
    $arr = $arr[$password];
    unset($arr[$password]);
    }
    if($username!== false){
    array_unshift($arr, $arr[$username]);
    unset($arr[$username]);
    }
    $arr = array_values($arr);


    var_export($arr);





    share|improve this answer






























      2














      I haven't tested this since I don't want to manually retype your array to real code.



      The code uses array_column to make a flat array of fieldname and searches for "password".

      If it's found it adds a copy of it last in the array and removes the original then does array_values to reindex the array.



      $fieldname = array_column($arr, "fieldName");
      $password = array_search("password", $fieldname);
      $username = array_search("username", $fieldname);


      if($password !== false){
      $arr = $arr[$password];
      unset($arr[$password]);
      }
      if($username!== false){
      array_unshift($arr, $arr[$username]);
      unset($arr[$username]);
      }
      $arr = array_values($arr);


      var_export($arr);





      share|improve this answer




























        2












        2








        2







        I haven't tested this since I don't want to manually retype your array to real code.



        The code uses array_column to make a flat array of fieldname and searches for "password".

        If it's found it adds a copy of it last in the array and removes the original then does array_values to reindex the array.



        $fieldname = array_column($arr, "fieldName");
        $password = array_search("password", $fieldname);
        $username = array_search("username", $fieldname);


        if($password !== false){
        $arr = $arr[$password];
        unset($arr[$password]);
        }
        if($username!== false){
        array_unshift($arr, $arr[$username]);
        unset($arr[$username]);
        }
        $arr = array_values($arr);


        var_export($arr);





        share|improve this answer















        I haven't tested this since I don't want to manually retype your array to real code.



        The code uses array_column to make a flat array of fieldname and searches for "password".

        If it's found it adds a copy of it last in the array and removes the original then does array_values to reindex the array.



        $fieldname = array_column($arr, "fieldName");
        $password = array_search("password", $fieldname);
        $username = array_search("username", $fieldname);


        if($password !== false){
        $arr = $arr[$password];
        unset($arr[$password]);
        }
        if($username!== false){
        array_unshift($arr, $arr[$username]);
        unset($arr[$username]);
        }
        $arr = array_values($arr);


        var_export($arr);






        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Nov 23 '18 at 11:29

























        answered Nov 23 '18 at 11:15









        AndreasAndreas

        15.8k31642




        15.8k31642






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53444943%2fhow-can-i-push-my-array-that-contains-a-specific-value-to-the-last-position%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            404 Error Contact Form 7 ajax form submitting

            How to know if a Active Directory user can login interactively

            TypeError: fit_transform() missing 1 required positional argument: 'X'