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 9022107
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T05:25:19+00:00 2026-06-16T05:25:19+00:00

I have a one-to-one key structure of zip codes to user located in a

  • 0

I have a one-to-one key structure of zip codes to user located in a .html that looks like…

...
'80135': 'user1',
'80136': 'user1',
'80137': '',
'80138': '',
'80202': 'user2',
'80203': 'user2',
'80204': '',
'80205': '',
'80206': '',
'80207': '',
...

I would like to take a bulk list zip codes for user3 and fill in or over-write old user. So for example if I have for user3, zip codes (80202,80203,80204) then my previous block of code would change to…

...
'80135': 'user1',
'80136': 'user1',
'80137': '',
'80138': '',
'80202': 'user3',
'80203': 'user3',
'80204': 'user3',
'80205': '',
'80206': '',
'80207': '',
...

The reason for text editor is to complete my set now, but ideally it would be nice to have a client application that our non-programmer team can update and make changes as they please, so a script for this would be nice for future plans.
I am passing the content into my site via…

var list_load = {<?php include_once('list.html'); ?>};

Because I believe some might have an alternate idea on storage of this information, this list is very long, 35,000 lines of code, so any ideas on completely changing my code consider a process to migrate data.

  • 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-16T05:25:21+00:00Added an answer on June 16, 2026 at 5:25 am

    Based on the information you provided I’m going to assume your example code is a subset of a JSON object. I’m also going to assume that you only have a one-to-one relationship of zip-codes to users in your object given that you did not explicitly state otherwise and given that the existing object structure would not allow for one-to-many relationship. Given all these assumptions the solution to your immediate problem is to load the JSON into PHP, make your changes there, and then overwrite the entire file with the updated JSON object.

    $json = file_get_contents('list.html');
    $array = json_decode($json, true);
    
    $oldUser = 'user2';
    $newUser = 'user3';
    $listZipCodes = array("80204"); // list of zip codes to update
    
    // Update the JSON based on user ...
    foreach ($array as $zipCode => $user) {
        if ($user === $oldUser) {
            $array[$zipCode] = $newUser;
        }
    }
    
    // Update the JSON based on zip code ...
    foreach (array_keys($array) as $zipCode) {
        if (in_array($zipCode, $listZipCodes)) {
            $array[$zipCode] = $newUser;
        }
    }
    
    $json = json_encode($array);
    
    file_put_contents('list.html', $json);
    

    Again, this is all assuming that list.html looks like this…

    {
        "80135": "user1",
        "80136": "user1",
        "80137": "",
        "80138": "",
        "80202": "user2",
        "80203": "user2",
        "80204": "",
        "80205": "",
        "80206": "",
        "80207": ""
    }
    

    Remember it has to be valid a valid JSON object notation in your list.html in order for PHP to be able to parse it correctly. Your existing example is not going to work in PHP because you’re using single quotes instead of double quotes, which is a requirement of the JSON spec. So you have to make sure that part is valid in your list.html file.

    Beyond that I highly discourage you to take this approach, because it causes a number of serious problems that can’t easily be solved. For example, you can not ensure your data won’t be corrupted using this approach as anyone two PHP scripts may attempt to overwrite the file at the same time (no data integrity). Also, you can’t easily make this scale without it costing you a lot of unnecessary CPU and memory problems if the list gets large enough. Additionally, you have no way to control who may edit the file directly and thus no way to control data flow to the underlying application code that tries to use that data.

    A better solution is to use a database and that way you can both control the data and its user privileges, plus you can provide a front-end for non-programmers to edit/modify/read the data through your front-end, via PHP.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have one key but different values for that key. I tried HashTable but
I was making one table that have two foreign key to another tables. But
Suppose I have two tables that are linked (one has a foreign key to
I have a table that has no primary key, and one cannot be created
It looks like Hadoop MapReduce requires a key value pair structure in the text
I have two dictionaries, that are of similar structure...meaning they(should) have the same key
How would one structure a table for an entity that can have a one
I have one very annoying issue with Eclipse under Windows. The key bindings for
I have a standard Panorama-based application, but one key item of data is repeated
I have four tables. Three of them are tables with one key and they

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.