Re Comma Separated List - Another Question
I can do the match perfectly but what i also need to do is create a third
list of comma separated values that are in both
eg:
List 1 => 1,2,3,4,5,6,7,8,11
List 2 => 1,3,4,5,6,7,10,23
Therefore
List 3 => 1,3,4,5,6,7
How do I populate this third list - I'm really stuck ....
View Complete Forum Thread with Replies
Related Forum Messages:
Comma Separated List In MySQL Field
say I have a list of categories in a field, and a page that is supposed to pull from the db based on a category. Is there any way I can do a query where it searches the contents of that field for the category in question? like SELECT FROM table WHERE category = $category but have it search the category field (the comma separated list for each entry) for the $category var
View Replies !
Comma Separated Values
What i've done is when the user enters the client list separated by commas..... this works, but I need to know how to warn the user when they have enter the client list with no commas. Is there some sort of function which does this or is it a regular expression thing??
View Replies !
Exploding Comma Separated In Array
I'm looking to explode the comma separated values in an array like this: Array ( => 10811 [1] => 7527,7556 ) and then add the exploded value as a new key in the array...like this: Array ( => 10811 [1] => 7527 [2] => 7556 )
View Replies !
Comma Separated Text Files
A client has requested that I make a php app which takes an uploaded image, reads the values and enters them into a database. I've made the upload script which works fine, and the script which enters the values into the database, the only thing left now is how do I make PHP read the file and extract the values? The file is a text file, each field comma separated.
View Replies !
Count Comma Separated Values In String
PHP form that checks $name doesn't already exist and then inserts them into mySQL database. All works except for the $counted variable. $list is a string that looks something like this: 123,2536,2346,332,546. So in this instance $counted should have a value of 5 because there are 5 values in the string. But it gets inserted as 0. Cannot see what I am doing wrong. Code:
View Replies !
Comma Seperated List Comparison
is it possible to compare acomma separated list aginst another eg comma list 1 => 1,2,3,4,5 comma list 2 => 3,5 can you check that 3 is in both, and 5 is in both, therfore they match? the comparison is to check that if product a who supplies products 1,2,3,4,5 can be used instead of product b who supplies 3,5 as product a already supplies them
View Replies !
How To Remove Last Comma From A Multiple List?
I have a multiple select list in my site where the values are inserted in a database table, in a column named available_country. I enter these values in the db separated with comma. I don't know however how to remove the last comma so it will be something like this: USA, Europe, Asia and not: USA, Europe, Asia, Here's what I tried but it didn't worked: ...
View Replies !
Array Form A Comma Delineated List
What's the best way to create an array from a comma delineated list? I have a string assigned to a variable that looks like this: 1,2,3,4 And I would like to create an array so that $arr[0] = 1 and $arr[1] = 2 etc. It seems so simple but I just can't crack it.
View Replies !
Regular Expression :: Find Word Matches To Words In A Comma-delimited List
What's the *right* way to find word matches to words in a comma-delimited list. For example, if I have the following comma-delimited list of categories in a mysql db field: gameboy, nintendo, playstation and I do a search, I know I can use regexp to do something like: select * from categories where regexp 'gameboy,' Notice that I have the comma in there to match the whole word and the comma without matching part of a word (to prevent unwanted matches such as "play" to "playstation" or "game" to "gameboy"). The problem I'm running into is words that match that match the end of each word next to the comma (in this example, "boy" and "station"). What's the right way to match a word *exactly* using regexp *without* also matching *part* of a word.
View Replies !
Zip Code Separated By Hyphens
I am storing 5 digit zip codes selected by clients like this, in a table. PHP Code: 56510-56511-56514-56519-56525-56529-56536-56541-56546-56547-56548-56549-56550-56552-56553-56554-56560-56561-56562-56563-56574-56579-56580-56581, In my query I am first selecting this data and replacing the hyphen with a comma, like this. PHP Code: $selectedzip[] = $row["selected_zip"]; $selectedzip1 = str_replace("-", "","", $selectedzip);Â Â $selectedzipstr = implode("','", $selectedzip1).
View Replies !
Separated Numerical Values
My source file contains numerical information shaped like this: 32,567,90 32,689,78 et cetera If I use (longint)$numstr I get 32 as value (logically). How can I convince php to ignore the, in these strings Probably in the manual, but I could not find an entry for this.
View Replies !
Count The Value Separated Through Explode Function
Currently i'm using an explode function to separate the value from a variable... For Example, $var1='username,user_type,filetoload' $var2=explode(",",$var1); So from here i can extract these 3 values separately... $extract1=$var2[0]; $extract2=$var2[1]; $extract3=$var2[2]; My question is, how do I want to count that this explode function has extracted 3 values? maybe from the variable $var1='username,user_type,filetoload' is it possible that i know $var1 contains 3 values ..?
View Replies !
Comparing Arrays - Separated By Commas
I have a MySQL database which has a load of musicians on it. Each musician has a field that stores their influences, which are separated by commas, e.g: The Beatles, The Beach Boys, Kiss etc etc. Now, what I would like to do is start with the influences of one musician, and then compare it to all the others to find the closest matches - i.e find the musicians that have (say) more than three influences i common. This would then allow you to see which musicians had the most influences in common with the primary one, the one you started with. Here's what I have in mind, it seems a little laborious - load the influences of the primary musician into an array using the explode command. Then step through each of the other musicians in a loop, each time putting their influences in to an array and checking to see how many matches there are between the two arrays. Whenever there is at least one match, the name of the musician and the number of matches would be put into a third array. This array would then be sorted at the end, so that the musicians with the most matches would be at the top, and the script could then display them. This would probably work, but if looking at several hundred or several thousand musicians, it would surely be quite slow - is there a better way? I don't particularly want to use a separate, normalised table at this point - I know it would be the quickest way but it would involve a lot of restructuring for me. I know that PHP has several clever inbuilt routines that might do this job for me, so if anyone can suggest anything I'd appreciate it.
View Replies !
Extracting Substrings Separated By New Line Character?
i have a variable with a string let's say 100 lines, one url per line i can't think out a easy way to get each of these urls separetely in order to insert them into a DB infact they are separated by a new line character (or in some cases space) so i just need a way to read the sub-strings between the new lines....
View Replies !
Comma Seperator
I have numbers retrieved from database which is quite big. Is it possible to give a comma seperator in the sql query or otherwise how can I format with a thousand comma separator?
View Replies !
Deleting Last Comma
The code below displays pet names like so: Fido, Bowser, Kittycat, Spot, and I want to delete only the last comma. I tried 'substr' and 'rtrim' and both of those delete the space and comma between each name, not just the last name as I'd like, so I end up with: Fido,Bowser,Kittycat,Spot, How would I delete only the last comma, so that it is this instead? Fido, Bowser, Kittycat, Spot Even with trim and substr, I end up with:
View Replies !
Exporting To CSV Contain Comma In It.
There are some text fields that I am exporting to CSV contain comma in it. And so when I open the csv file, everything is shifted. e.g. "Apple, Banana, Orange", "Excellent", "12345" gives me 5 columns instead of 3 in the csv: Apple Banana Orange Excellent 12345 How can I solve this problem?
View Replies !
Formatting With A Comma>
i inserted a salary into mysql with a text file but the command i said was to end field with comma, so i just made 750,000 like this in the txt file like this 750000. ok so how can i format my php to display it as the 750,000 and even better add a floating dollar sign would help as well Code:
View Replies !
Stripping Last Comma
When pulling flavors from a mySQL database, I want to strip the last comma from the array, however I'm not sure how to do this. The stripped down code is below with the comma I want stripped in bold red: $query2 = "SELECT flavors from chip_stan_flav"; $result2 = @mysql_query($query2) or Die("Couldn't execute query"); while ($row2 = mysql_fetch_array($result2)) { printf ("%s, ", $row2[flavors]); }
View Replies !
Sending Comma In Url
I have a page that has a drop down menu, when item is selected the request is send to info.php?item=selectedIndex. Everything works, however when I have selected value with a comma: "Comany, Inc" the url redirection does not work. Is there a function in php I should use to encode url, or commas are not allowed at all.
View Replies !
Only Split First Comma
i have to split a substring from a string how do it? my requirement is i have a variable $var =,1,4,7 out put should be like $var =1,4,7(split first comma from the value.
View Replies !
Remove First Comma
I have this string: ",c2=5,c3=6,c4=5......" Now I need to remove the first comma. I know it is simple, but I can find the right command.
View Replies !
Seperating An Array With A Comma
I'm trying to seperate the output of an array with a comma. I can't figure out how to eliminate the last comma. Here is my code: $result = mysql_query($query,$connection) or die (mysql_error()); $fw = fopen("/var/www/html/ecast/windex/graph.html","w"); fwrite($fw, "/ "); if ($new_rows = mysql_fetch_array($result)){ do{ fwrite($fw, $new_rows[0]); fwrite($fw, ", "); }while($new_rows = mysql_fetch_array($result)); } fwrite($fw, " /"); fclose($fw); ?> Output: / 85, 86, 87, 89, / How can I eliminate that last comma?
View Replies !
Removing A Comma From The End Of An Array
I am reading a file into an array using this: $listFile = "add2db.txt"; if (!($fp = fopen($listFile, "r"))) exit("Unable to open the input file, $listFile."); $buffer = fread($fp, filesize($listFile)); fclose($fp); The very last character in that $listFile will always be a comma. What I need to do is remove that last comma (and only that comma) from $buffer before I can continue on. What do I need to do to accomplish this?
View Replies !
Comma Delimited File
I am trying to read comma delimited rows of text. The problem is that some fields may be encapsulated in "" - particularly the text fields but not numeric fields. Is there a simple efficient way to parse the fields with comma but also strip off the "" encapsulating some of the fields with php? The problem is the "" encapsulation is optional. Some fields will have it, some won't.
View Replies !
How To Instert Comma Into Number?
I am having users submit large numbers into a form, and when those values are returned to them later I want to have the commas in the correct places. ie. 123456.00 changes to 123,456.00. Is there a function that does this conversion? Also, how would I ensure that the number is always displayed with 2 decimal places, ie. 123 changes to 123.00, but 123.00 remains 123.00.
View Replies !
Loops - Not Print The Very Last Comma
How can I tell the below to not print the very last comma after $line[id] if it is the last record of the loop? while($line= mysql_fetch_array($getresult, MYSQL_ASSOC)){ print "["$line[lastName] $line[firstName]","$line[id]"],"; }
View Replies !
Alphabet Seperated By A Comma
How would I take every letter in the alphabet seperated by a comma and mix them up in every which way possible with only four letters, so that it comes up differently each time and has only 30 on each line ? Example: aaab,awdr,cfty,bvfg,ewvt, and so on so that in each line it has 30 different ones
View Replies !
Extra Comma In Update Sql
I am using a foreach loop to create the statement. Everything looks good with the sql statement when I echo it; but the last update field has a comma , that is not needed. How to I account for the last $key => $value set in the array that match my criteria and not have a comma? $sql = "UPDATE facform SET "; foreach ($_POST as $key => $value) { if($key != 'submit' && $value != ''){ $sql .= "$key = $value, "; } } $sql .= "WHERE id = $id";
View Replies !
Adding Comma To Data
I have an SQL database with a price field. The field is INT(10), as I do not need decimal to show cents. My problem is that when the data is sorted and displayed, it shows as "20000" or "200000" or "2000", etc. I need it to have commas like so - "20,000" or "200,000" or "2,000". Is there an easy way to "format" the output?
View Replies !
Delete String After Comma
How would I truncate a string after a certain character? I don't know the index of that character. I think this is close, but I need to replace the 18 with the index of the comma in the variable mystring since I won't know where the user put in a comma. $mystring = "Hello I'm a string, and I have a comma."; $mystring = substr_replace($mystring , '', 18, -1); my result of echoling $mystring would be: Hello I'm a string"
View Replies !
Remove Ending Comma
I have this code: <?php $sql = "SELECT * from cfm_lower_level_story_categories WHERE tl_section_id=1"; $result = mysql_query($sql) OR die(mysql_error()); while ($row = mysql_fetch_assoc($result)){   rtrim( ', ' );   echo '"';   echo $row['subsection_name'];   echo '"';   echo','; } ?>
View Replies !
Comma Delineated Files
I have an file whose contents are as follows: "test","com,ma","food" $file_contents = array('"test"','"com,ma"','"food"'); Doing explode(',',$file_contents) wouldn't be sufficient because the resultant array would have four entries - not three - and would instead read like this: $file_contents = array('"test"','"com','ma"','"food"');
View Replies !
Seperator Instead Of A Comma For Listed Items In DB?
I'm making a recipe database, and need to have DB fields in mySQL that will have lists of values that would get sent to an array to be worked on. I anticipate that at times a comma will need to be used in the value itself. So, what's a commonly used symbol or something that people tend to use as a separator of a list that would then be used in the split() function to send the elements into an array?
View Replies !
How To Check If It's The Last Result And Remove Comma
I am wondering if anyone could help. I have a loop that displays my results and places a comma after each. The problem is that when the last result is displayed, it shows the comma. Example: for loop{ echo $row['test'].', '; } displays... test1, test2, test3, Notice after test3, there is still a comma? How do I remove it and have it display... test1, test2, test3
View Replies !
Number Format - Put The Comma In The Field.
Currently, if the user enters a list_price value of 25,000, my program is changing it to 25; if I enter 25000 (w/o the comma), it's displaying OK, but I'd like to be able to put the comma in the field. What do I need to change/add to accomplish this? Code:
View Replies !
Unexpected 'comma' Parse Errors
I've been trying to code this e-mail submit page for a questionaire. The values from the questionaire are passed to the script, there is some error handling that is carried out, and the e-mail is then sent. However, there appears to be a problem with the commas in the seperation of variables and of array values. But I am unable to fix this as the syntax (the mail() function itself is an example of this) matches exactly what is in the main PHP manual. Code:
View Replies !
|