Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8902641
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T01:39:53+00:00 2026-06-15T01:39:53+00:00

I hope I am explaining this right; as an example, I would like the

  • 0

I hope I am explaining this right; as an example, I would like the user_id:id of the matching value: in a returned jSON Array/Object like so…

[{"user_id":"1","value":"92056,92054,92018"},{"user_id":"3","value":"92056"},
{"user_id":"2","value":"Massachusetts, Wyoming, Tennessee"},
{"user_id":"5","value":"California"},
{"user_id":"9","value":"New Mexico, Mississippi, Washington"},
{"user_id":"11","value":"Nevada"},{"user_id":"8","value":"Oklahoma, Louisiana"},
{"user_id":"6","value":"Montana, Oregon"},
{"user_id":"10","value":"Virginia, Illinois"}]

For example, if my source is 92056, I want to get “1”, because my user_id for 92056 is “1”.

If it is New Mexico, I want “9” and so on.

This value can consist of several hundred zip codes, so I would like a way to rapidly search for either these values or like values as this will not ever be duplicated; each user_id will have multiple unique territories or “value”.

In case this comes up, I am pulling the data from the database with PHP and passing into a JavaScript variable like so (in WordPress)…

 <?php
        global $wpdb;
        $fullPHP = $wpdb->get_results("SELECT user_id, value FROM " . "refer_cimy_uef_data;");
 ?>
        var phpreps = JSON.stringify(<?php echo json_encode($fullPHP); ?>);
        $("#phpoutput").html(phpreps);
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T01:39:55+00:00Added an answer on June 15, 2026 at 1:39 am

    You’re making this too hard on yourself. Convert the ‘value’ property to an array before you send it to the browser client, and just use indexOf on each value array to check if the search query exists. In the following code, the search function at the bottom is very simple. The first part is some client-side conversion code for converting your value properties into proper arrays.

    //pre-process the data to put 'value' into an array. This would be better done from the server in the initial response.
    
    var input = (function(){
    
        var arr = [
            {"user_id":"1","value":"92056,92054,92018"},{"user_id":"3","value":"92056"}, 
            {"user_id":"2","value":"Massachusetts, Wyoming, Tennessee"},
            {"user_id":"5","value":"California"},
            {"user_id":"9","value":"New Mexico, Mississippi, Washington"},
            {"user_id":"11","value":"Nevada"},
            {"user_id":"8","value":"Oklahoma, Louisiana"},
            {"user_id":"6","value":"Montana, Oregon"},
            {"user_id":"10","value":"Virginia, Illinois"}
        ];
    
        arr.forEach(function(item, index){ //remove extra space from some splitting
            arr[index].value = arr[index].value.replace(/,\s/gi,',').split(',');
        });
    
        return arr;
    
    })();
    
    
    var search = function(val){
    
        for(var i=0, len=input.length; i<len; i++){
    
            if( input[i].value.indexOf(val) > -1 ) return input[i].user_id;
    
        }
    
        return null;
    
    }
    
    console.log( search('New Mexico') );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hope someone could help me with this: I would like to have a column
I hope I'm explaining this as accurately as possible, and I want to know
I hope I'm explaining this well. I'm struggling with this query: I have this
Ok, there is a good chance I'm not explaining this correctly but I hope
So, I am having a very difficult time explaining my problem, I hope this
Hope this question is not stupid since I am an amateur web designer. I
hope someone can answer this. Here is some sample code. namespace std { #ifdef
hope all is swell! I was hoping I had cracked this problem but it
Hope someone will give me a hand with this problem I have. So here
Hope I'm asking this correctly: I have a project Projects.Client I have my class

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.