Buying Will send you $10 dollars (paypal) to fix this duplicated array

Discussion in 'Programming' started by tdd1984, Apr 25, 2018.

  1. #1
    The first person that responds, that can fix this problem successfully. I will send you $10 through paypal. Please see below, I am trying to avoid duplicate desiredjobposition returning.

    I only one each desiredjobposition to return only 1 time, excluding duplicates.

    
    $array = json_decode($json_string);
    
    
    
    
    //start of our select menu
    echo "<select>";
    //Our Categories Menu
    foreach($array->results as $key => $object){
      ?>
    
      <option value="<?PHP echo $object->meta_data-> desiredjobposition[0];?>"><?PHP echo $object->meta_data-> desiredjobposition[0];?></option>
    
     
       
    <?PHP }
    echo "</select>";
    ?>
    PHP:

     
    tdd1984, Apr 25, 2018 IP
  2. tdd1984

    tdd1984 Well-Known Member

    Messages:
    2,357
    Likes Received:
    42
    Best Answers:
    0
    Trophy Points:
    150
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #2
    I will not respond to pages, I said post the code here.
     
    tdd1984, Apr 25, 2018 IP
  3. tdd1984

    tdd1984 Well-Known Member

    Messages:
    2,357
    Likes Received:
    42
    Best Answers:
    0
    Trophy Points:
    150
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #3
    You got that from stack flow ding dong. I already seen the code and it won't work with ours.
     
    tdd1984, Apr 25, 2018 IP
    Joseph_F likes this.
  4. creativeGenius

    creativeGenius Well-Known Member

    Messages:
    273
    Likes Received:
    5
    Best Answers:
    1
    Trophy Points:
    120
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #4
    if this is a normal key => value array, you can just use, array_unique()
    http://php.net/manual/en/function.array-unique.php

    $array = json_decode($json_string);
    
    $unique = array_unique($array->results);
    
    //start of our select menu
    echo "<select>";
    //Our Categories Menu
    foreach($unique as $key => $object){
    ?>
    
    <option value="<?PHP echo $object->meta_data-> desiredjobposition[0];?>"><?PHP echo $object->meta_data-> desiredjobposition[0];?></option>
    
    
    
    <?PHP }
    echo "</select>";
    ?>
    PHP:
     
    creativeGenius, Apr 25, 2018 IP
    StaSen likes this.
  5. tdd1984

    tdd1984 Well-Known Member

    Messages:
    2,357
    Likes Received:
    42
    Best Answers:
    0
    Trophy Points:
    150
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #5
    I will do a print_r and show you what the array looks like, one minute.
     
    tdd1984, Apr 25, 2018 IP
  6. tdd1984

    tdd1984 Well-Known Member

    Messages:
    2,357
    Likes Received:
    42
    Best Answers:
    0
    Trophy Points:
    150
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #6

    I will do a print_r and show you what the array looks like, one minute.
     
    tdd1984, Apr 25, 2018 IP
  7. tdd1984

    tdd1984 Well-Known Member

    Messages:
    2,357
    Likes Received:
    42
    Best Answers:
    0
    Trophy Points:
    150
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #7

    http://www.backofficeexport.com/api/inapi/bei-api.php go to this link and you'll see the result. I limited the results though to 1. But the
    wpleads_desiredjobposition

    is what I am trying to get, only unique ones though. I mean not repeated over,over, over for every person.
     
    tdd1984, Apr 25, 2018 IP
  8. creativeGenius

    creativeGenius Well-Known Member

    Messages:
    273
    Likes Received:
    5
    Best Answers:
    1
    Trophy Points:
    120
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #8
    
    $array = json_decode($json_string);
    $positions = array();
    foreach($array->results as $key => $object){
        if( !in_array($object->meta_data-> desiredjobposition[0], $positions) )}{
            $positions[] = $object->meta_data-> desiredjobposition[0];
        }
    
    }
    
    //start of our select menu
    echo "<select>";
    //Our Categories Menu
    foreach($positions as $position){
    ?>
    <option value="<?PHP echo $position; ?>"><?PHP echo $position; ?></option>
    
    <?PHP }
    echo "</select>";
    ?>
    
    Code (markup):
    I'm assuming there that you are getting the correct text for $object->meta_data-> desiredjobposition[0] since i can't test right now
     
    Last edited: Apr 25, 2018
    creativeGenius, Apr 25, 2018 IP
  9. tdd1984

    tdd1984 Well-Known Member

    Messages:
    2,357
    Likes Received:
    42
    Best Answers:
    0
    Trophy Points:
    150
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #9
    yes checking this now.
     
    tdd1984, Apr 25, 2018 IP
  10. tdd1984

    tdd1984 Well-Known Member

    Messages:
    2,357
    Likes Received:
    42
    Best Answers:
    0
    Trophy Points:
    150
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #10

    ok great it worked, whats your paypal?
     
    tdd1984, Apr 25, 2018 IP
    StaSen likes this.
  11. creativeGenius

    creativeGenius Well-Known Member

    Messages:
    273
    Likes Received:
    5
    Best Answers:
    1
    Trophy Points:
    120
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #11
     
    Last edited: Apr 25, 2018
    creativeGenius, Apr 25, 2018 IP
  12. tdd1984

    tdd1984 Well-Known Member

    Messages:
    2,357
    Likes Received:
    42
    Best Answers:
    0
    Trophy Points:
    150
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #12
    where you from?
     
    tdd1984, Apr 25, 2018 IP
  13. tdd1984

    tdd1984 Well-Known Member

    Messages:
    2,357
    Likes Received:
    42
    Best Answers:
    0
    Trophy Points:
    150
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #13
    payment sent.
     
    tdd1984, Apr 25, 2018 IP
  14. creativeGenius

    creativeGenius Well-Known Member

    Messages:
    273
    Likes Received:
    5
    Best Answers:
    1
    Trophy Points:
    120
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #14
    thanks,

    i'm from the Philippines
     
    creativeGenius, Apr 25, 2018 IP
  15. tdd1984

    tdd1984 Well-Known Member

    Messages:
    2,357
    Likes Received:
    42
    Best Answers:
    0
    Trophy Points:
    150
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #15
    Your kidding me, I am living in PH right now. In Manila/Makati.
     
    tdd1984, Apr 27, 2018 IP
    StaSen likes this.