1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

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:

    SEMrush
     
    tdd1984, Apr 25, 2018 IP
    SEMrush
  2. StaSen

    StaSen Well-Known Member

    Messages:
    1,064
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    155
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #2
    Sent you solution, Check your inbox.

    Best Regards,
    Stasen
     
    StaSen, Apr 25, 2018 IP
  3. tdd1984

    tdd1984 Well-Known Member

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

    StaSen Well-Known Member

    Messages:
    1,064
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    155
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #4
    I already coded a function before to remove duplicated records in array you can use it
    function unique_multidim_array($array, $key) {
    $temp_array = array();
    $i = 0;
    $key_array = array();
    
    foreach($array as $val) {
    if (!in_array($val[$key], $key_array)) {
    $key_array[$i] = $val[$key];
    $temp_array[$i] = $val;
    }
    $i++;
    }
    return $temp_array;
    }
    PHP:
     
    StaSen, Apr 25, 2018 IP
  5. StaSen

    StaSen Well-Known Member

    Messages:
    1,064
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    155
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #5
    Check your inbox please.
     
    StaSen, Apr 25, 2018 IP
  6. tdd1984

    tdd1984 Well-Known Member

    Messages:
    2,355
    Likes Received:
    40
    Best Answers:
    0
    Trophy Points:
    150
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #6
    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
  7. creativeGenius

    creativeGenius Active Member

    Messages:
    272
    Likes Received:
    5
    Best Answers:
    1
    Trophy Points:
    70
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #7
    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.
  8. StaSen

    StaSen Well-Known Member

    Messages:
    1,064
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    155
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #8
    Same Solution. Perfect
     
    StaSen, Apr 25, 2018 IP
  9. tdd1984

    tdd1984 Well-Known Member

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

    tdd1984 Well-Known Member

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

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

    tdd1984 Well-Known Member

    Messages:
    2,355
    Likes Received:
    40
    Best Answers:
    0
    Trophy Points:
    150
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #11

    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
  12. creativeGenius

    creativeGenius Active Member

    Messages:
    272
    Likes Received:
    5
    Best Answers:
    1
    Trophy Points:
    70
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #12
    
    $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
  13. tdd1984

    tdd1984 Well-Known Member

    Messages:
    2,355
    Likes Received:
    40
    Best Answers:
    0
    Trophy Points:
    150
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #13
    yes checking this now.
     
    tdd1984, Apr 25, 2018 IP
  14. tdd1984

    tdd1984 Well-Known Member

    Messages:
    2,355
    Likes Received:
    40
    Best Answers:
    0
    Trophy Points:
    150
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #14

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

    creativeGenius Active Member

    Messages:
    272
    Likes Received:
    5
    Best Answers:
    1
    Trophy Points:
    70
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #15
     
    Last edited: Apr 25, 2018
    creativeGenius, Apr 25, 2018 IP
  16. StaSen

    StaSen Well-Known Member

    Messages:
    1,064
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    155
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #16
    congratulations!
     
    StaSen, Apr 25, 2018 IP
    creativeGenius likes this.
  17. tdd1984

    tdd1984 Well-Known Member

    Messages:
    2,355
    Likes Received:
    40
    Best Answers:
    0
    Trophy Points:
    150
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #17
    where you from?
     
    tdd1984, Apr 25, 2018 IP
  18. tdd1984

    tdd1984 Well-Known Member

    Messages:
    2,355
    Likes Received:
    40
    Best Answers:
    0
    Trophy Points:
    150
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #18
    payment sent.
     
    tdd1984, Apr 25, 2018 IP
  19. creativeGenius

    creativeGenius Active Member

    Messages:
    272
    Likes Received:
    5
    Best Answers:
    1
    Trophy Points:
    70
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #19
    thanks,

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

    tdd1984 Well-Known Member

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