Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 10/07/2019 in all areas

  1. I don't like having side conversations not specific to the thread topic,. But since this appears to be more instructive, I thought I'd respond to this question. There are a multitude of uses for hashes aside from passwords. It all depends on the developer identifying a need and implementing it. Basically any time you need to compare complex data. Here are a couple examples: 1. File comparison. For example, let's say you have an application that picks up a file every hour for processing. The file gets written regularly from some process outside of your application. BUT, even though it gets written regularly, it may not have any new data. I might store a hash when I process the file. Then, every hour I will run a hash on the current file contents. If the hash is the same, then I don't process it. There are many use cases where file comparison is needed and where hashing will fill that need. 2. Creating a unique key. In a mp3/music app I worked on, I needed to quickly look for duplicates based on a combination of multiple meta data fields before I inserted new records into the database. Since I was dealing with raw "text" values from the files being process I had not yet determine the unique IDs for some of that meta data. So, I could not use a unique constrain on a single table and it would require a query with multiple JOINs in order to check for a duplicate - on every MP3 file. The processing was executing against hundreds/thousands of files, so I wanted an efficient process. In order to simplify this process, I just created a unique key using a hash on the multiple values and could just check that value against a single table in the DB.
    1 point
  2. I wasn't trying to sound sarcastic, but I still don't follow what you are trying to accomplish in real life. Why do you want a product name, color and every SKU associated with it on one row? What happens if you have 25 SKUs of Blue Pliers? If this is a report, I think there is a better way to communicate things. Follow me?
    1 point
  3. According to your first post you have an array of paths/filenames EG $arr = [ 'xxx/yyy/aaa-bbb-xxx.txt', 'xxx/yyy/aaa-vcf.txt', 'xxx/yyy/aaa-bbb-vbn.txt', 'xxx/yyy/aaa-bbb-vvv.txt', 'xxx/yyy/aaa-bbb-vcf.txt', 'xxx/yyy/aaa-bbb-xcv.txt' ]; If that is the case, I think your preg_split line needs to add a "." so the file extension is excluded. I.E. if(preg_split("/[-.]+/", $userBase)[2] == $keyword) ^ then echo array_search_partial($arr, 'vcf'); //--> 4 Also, your function should return something (false ?) if no match is found.
    1 point
This leaderboard is set to New York/GMT-04:00
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.