1. The forums will be archived and moved to a read only mode in about 2 weeks (mid march).

Solved Coding problem

Discussion in 'Development' started by instantlyta, Feb 26, 2018.

  1. instantlyta

    instantlyta Slime

    Messages:
    96
    GitHub:
    intagaming
    Ermm... It skips the index 13? No Google answer?
    Picture explanation: incremental index array: no associative form of json. Disruption: associative.
    I believe I'm using pmmp's PHP 7.2.1 downloaded at 21/1/2018 on https://ci.appveyor.com/project/pmmp/php-build-scripts. Is there any update about this recently?
    upload_2018-2-26_17-32-33.png

    Mintty, can't be edited:
    upload_2018-2-26_17-27-20.png
     
    Last edited: Feb 28, 2018
  2. Sandertv

    Sandertv Zombie Pigman Poggit Reviewer

    Messages:
    786
    GitHub:
    Sandertv
    Please explain what exactly your issue is. You're getting the entity ID, which increments for every entity. Because you hardly posted any code however, we can't find out why apparently not all entities go through that bit of code you posted.
     
  3. instantlyta

    instantlyta Slime

    Messages:
    96
    GitHub:
    intagaming
    Its the elements of the smaller array. The index of the outer array is not affected by the entityId whatsoever. Besides, that is the on-the-go status of the array. It runs just like a script. No other code is run while that code is running.

    PHP:
    $a = ["a""b""c"];
    $a[] = "d";
    // $a is now [0 => "a", 1 => "b",  2 => "c", 4 => "d"]
     
  4. instantlyta

    instantlyta Slime

    Messages:
    96
    GitHub:
    intagaming
    Yes that is fine. I would like to fix that myself.
    PHP:
    self::$entityEquiping[count(self::$entityEquiping)] = [$entity->getLevel()->getId(), $entity->getId(), $task->getTaskId()];
    // Simplified version: $a[count($a)] = "d";
    It's internal PHP bug. Don't ask anyone.
     
  5. robske_110 (Tim)

    robske_110 (Tim) Wither Skeleton Poggit Reviewer

    Messages:
    1,342
    GitHub:
    robske110
    PHP:
    $a = ["a""b""c"];
    $a[] = "d";
    var_dump($a);
    Output:
    array(4) {
    [0]=>
    string(1) "a"
    [1]=>
    string(1) "b"
    [2]=>
    string(1) "c"
    [3]=>
    string(1) "d"
    }
    PHP works fine. (at least in this case)
     
  6. instantlyta

    instantlyta Slime

    Messages:
    96
    GitHub:
    intagaming
    Of course it works fine for years and for my 0 -> 12 index until the 14th element comes up. It constantly happening, with the server restarted, not just once.
    It's a pmmp plugin by the way
     
  7. robske_110 (Tim)

    robske_110 (Tim) Wither Skeleton Poggit Reviewer

    Messages:
    1,342
    GitHub:
    robske110
    I don't really understand what issue you are having.
    are you saying
    $arr[] = $val;
    $arr[count($arr)] = $val;
    behave differently?
     
  8. instantlyta

    instantlyta Slime

    Messages:
    96
    GitHub:
    intagaming
    It's the same. My problem is that my code doesn't behave right every single circumstance. The
    $arr[] = $val;
    should put the [1,39,11899] to the index 13, not 14. Do you understand my problem ?
     
    Last edited: Feb 27, 2018
  9. instantlyta

    instantlyta Slime

    Messages:
    96
    GitHub:
    intagaming
    Have you see my code in the image by the way ?
     
  10. robske_110 (Tim)

    robske_110 (Tim) Wither Skeleton Poggit Reviewer

    Messages:
    1,342
    GitHub:
    robske110
    PHP:
    <?php
    $arr 
    = [];
    for(
    $i 0$i 13$i++){
        
    $arr[] = "some_val";
    }
    var_dump("Before(".count($arr)."):".json_encode($arr));
    $arr[] = "some_val";
    var_dump("After(".count($arr)."):".json_encode($arr));
    Code:
    string(155) "Before(13):["some_val","some_val","some_val","some_val","some_val","some_val","some_val","some_val","some_val","some_val","some_val","some_val","some_val"]"
    string(165) "After(14):["some_val","some_val","some_val","some_val","some_val","some_val","some_val","some_val","some_val","some_val","some_val","some_val","some_val","some_val"]"
    
    Do you alter your self::entitiyEquiping somewhere else?
     
  11. instantlyta

    instantlyta Slime

    Messages:
    96
    GitHub:
    intagaming
    1. That's all my code. I know my code enough, again, that is a **continuous** script. How can the 2 var_dump next to each other and with the array in-between can be altered?
    2. I don't say your code is either wrong or right. My problem is the problem with that PHP internally. I would say again, that my problem, with that PhpStorm IDE screenshot taken live and the pmmp console log couldn't be edited, is not producing the array it should be.
     
  12. instantlyta

    instantlyta Slime

    Messages:
    96
    GitHub:
    intagaming
    All I want to access is how the PHP binary is not pushing that value to the index 13. Doesn't it mean nothing, that this just works for every circumstances except this one?
     
  13. instantlyta

    instantlyta Slime

    Messages:
    96
    GitHub:
    intagaming
    Thanks anyway. I think I'm the bad person so no one accepts my bug, as it can't be reproducible and I don't have any knowledge of debugging php.
     
  14. Jack Noordhuis

    Jack Noordhuis Zombie Pigman Poggit Reviewer

    Messages:
    618
    GitHub:
    JackNoordhuis
    You're forgetting that array indexes start at zero. The next correct index would be the count of the existing array elements minus one.
    PHP:
    self::$entityEquiping[count(self::$entityEquiping) - 1] = [$entity->getLevel()->getId(), $entity->getId(), $task->getTaskId()];
     
  15. robske_110 (Tim)

    robske_110 (Tim) Wither Skeleton Poggit Reviewer

    Messages:
    1,342
    GitHub:
    robske110
    well, in his original code he doesn't use count.

    And @instantlyta : My question remains:
    Do you alter your self::entitiyEquiping somewhere else?
     
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.