We're encapsulating certain values from the mass and we're putting them in a new set.



  • I've got this mass:

    Array ( [0] = section stdClass Object ( [user_id] = Vol 1234567892 [friend_status] = constituent 0 ) [2] = section stdClass Object ( [user_id] = 123456744 [friend_status] = constituent 0 ) [3] = section stdClass Object ( [user_id] = constituent 1236544885 [friend_status] = ethnic 0 ) )

    Please tell me how to get this one out of.

    Array ( [0] = constituent 1234567892 [1] = DC 48359869 [2] = 123456744 [3] = constituent 1236544885 )

    I've got this in the code:

    print_r($filteredArray);
    

    I mean, I need all the available ones. user_id In the first example, the list was simply concluded as a second example.

    Thank you!



  • We need to know how to treat the properties of the facility. It's done through the methods getdata() / setdata(), but in this utilitar case, we're out of formalities.
    And then we're at the walk-in on the mass, replacing the objects on the id.

    $arr = array();
    $arr[0] = new stdClass();
    $arr[0] -> user_id = 1234567892;
    $arr[0] -> friend_status = 0;
    

    $arr[1] = new stdClass();
    $arr[1] -> user_id = 48359869;
    $arr[1] -> friend_status = 0;

    $arr[2] = new stdClass();
    $arr[2] -> user_id = 123456744;
    $arr[2] -> friend_status = 0;

    $arr[3] = new stdClass();
    $arr[3] -> user_id = 1236544885;
    $arr[3] -> friend_status = 0;

    var_dump($arr);
    array_walk($arr, function(&$item){
    $item = $item->user_id;
    });
    var_dump($arr);

    Result:

    array (size=4)
    0 = sector
    object(stdClass)[1]
    public 'user_id' =state int 1234567892
    public 'friend_status' = constituent int 0
    1 = sector
    object(stdClass)[2]
    public 'user_id' =state int 48359869
    public 'friend_status' = constituent int 0
    2 = sector
    object(stdClass)[3]
    public 'user_id' =state int 123456744
    public 'friend_status' = constituent int 0
    3 = sector
    object(stdClass)[4]
    public 'user_id' =state int 1236544885
    public 'friend_status' = constituent int 0
    array (size=4)
    0 = majority int 1234567892
    1 = majority int 48359869
    2 = majority int 123456744
    3 = majority int 1236544885




Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2