Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 3 years ago.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Improve this question
I am wondering what the proper name is for an array held in a string (string that holds an array).
Commonly used for storing tags or multiple variables in a database
EXAMPLE 1 (Image URLs for item):
url1,url2,url3
Example 2 (Video Tags): tag1,tag2,tag3
Example 3 (quests complete): 2,3,1,6,7,4
These strings would get converted into an array with an explode in PHP usually.
To clarify: What is the proper name for these types of strings?
These values are stored as comma separated values or CSV. This is a relatively common practice as a way to store multiple data points uder a single entry.
From wikipedia
A comma-separated values (CSV) file is a delimited text file that uses a comma to separate values. A CSV file stores tabular data (numbers and text) in plain text. Each line of the file is a data record. Each record consists of one or more fields, separated by commas. The use of the comma as a field separator is the source of the name for this file format.
Hope this helps,
Related
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 6 years ago.
Improve this question
I have to create a sort of poll with random questions and I wanted to ask you whether the best way to store these random questions in my MySQL db would be
storing the questions as string, which means I would extract via PHP the random questions from the bunch I've got and save them in the database like this
storing the questions' IDs as a string (e.g. "1_2_3_4_5") and then using PHP I get an array out of it using explode() and take out of the array with the questions' texts using the IDs:
Table.
or please suggest me a better method.
Thank you really much, appreciate your support, I hope I explained it clearly and sorry for mistakes.
I'd create a table for Questions and a table for QuestionResponses, at a minimum. QuestionResponses can have a foreign key reference to Questions, along with a VARCHAR(SOMELENGTH) field for storing the response.
I would go with your first option. You can just store the questions as strings in the database, and use php/pdo to randomly select the amount of questions you want per time in an array, then print out the array content randomly. (English is hard sometimes, so i'll explain again)...
Say you want to produce 5 random questions per user that tries to use the application, you can have at least 50 questions in the database stored as string, then "randomly" select 10 questions from the database (this is to avoid selecting all the questions every time or selecting the same set of questions), from the 10 randomly selected questions (which is now in an array), you can randomly print out 5 for the user.
So you have two sets of randomization.
I hope this makes a little sense and helpful too.
I can explain myself better if you have any more questions.
Thank you.
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 7 years ago.
Improve this question
I would love a starting point for this problem.
I have a list of IP's retrieved from a source, the IP's along with ID's get stored in a table.
I want to check the table against my array each time it grabs new data, to make sure the array is not putting a duplicate IP in the said table.
Wrong way to think about the problem. Let the database control the data. You can ensure no duplicates by defining a constraint or unique index on the IP column (they are pretty much equivalent):
create unique index unq_iptable_ip on iptable(ip);
Then, if you attempt to insert a duplicate ip, the database won't let you. This ensures data integrity, and the database can do this better than you can (consider what happens if multiple users try to modify the table at the same time).
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I am writing a small program where I want to extract user input strings from MySQL database. But I am not looking for exact matching strings. For example
If user types amazon then it should extract amazon from the database. But if user types amazonn or amazo or amozon it should still retrive amazon because it is the nearest word to the misspelled word.
This is something similar to google suggestions while searching. Is there anyway to define a function like this in PHP? Do i have to import dictionary and compare with it?
You could use strpos() in two ways
How do I check if a string contains a specific word in PHP?
Search for the DB string in the string that the user inputted.
And the other way around:
Search for the string that the user inputted in the DB string.
The problem with this is that you only cover differences at the outside of the string
such as amazo or amazonn but not amozon
Or you could use levenshtein() and similar_text() as stated in the comments.
Good example code with suggestions:
https://codereview.stackexchange.com/questions/27173/php-spell-checker-with-suggestions-for-misspelled-words
That should be covered in an entirely different way...
I think you want both checks but everything is going to be difficult without a dicitonary so I suggest importing one ;)
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I'm trying to get a big number of data (about 3M rows) and I have only two options to do that.
Call an API then recover the 3M JSON objects.
Import a CSV file containing the 3M rows.
I didn't test any of these solutions yet to tell which one is best in terms of speed.
If you want to retrieve simple data as lists or rows with some columns the option #2 is the good one, you can read below a set of advantages and disadvantages:
Pros
Less bandwidth needed because JSON needs more syntax characters to keep the format while CSV is as simple as use a character separator
Process data is faster because only needs to split by the separator character while JSON needs to interpret the syntax
Big data technology as Hadoop has an integrated parse for CSV format while needs a specific function for parse JSON (for example using Hive language).
Cons
Unstructured data and more difficult to be read by humans
You have to take care as separator character cannot appear in data fields.
If the data will contain complex data as tuples, arrays and structures JSON are better because:
Keeps a clear and structured format
Doesn't repeat data to reference it because one label could contain multiple data.
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
Before I re-invent the wheel, I was hoping someone knew of a popular PHP based database table "viewer" with configurable per-column filtering by enumerated values and includes export abilities. Ideally, this would be a tool for data exploring/viewing/reporting purposes.
edit -- i seem to be angering people... My apologies. Yes, i searched google first, then stack overflow, then both again with different terms.
This is what Im looking for:
something we could call along the lines of "tableview.php" and pass $_REQUEST the following:
table name
filter column names (would be used to filter the contents of the page - enumeration of values would occur on load)
subcolumns that would be visible in a modal or pop-in only when you click on a row
export to csv, pdf, xls, etc
I am sure you are looking for this
see the demo here