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 Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Batch File Deleting And Folder Deleting
I have a folder in my web site where I used php to create and copy in files. but now I can't delete them easily. The only way I know how that is possible is through php. I get an error the following ftp error: 550 th: Permission denied I had the chmod() set to 0777 on every file and folder. But I still seem to loss control over the files when I try and do things with them through other means. I think it is because the user I use to access the files via ftp a diffrent user. So I tryed to add a function with chown() for the new files I was posting and uploading. It didn't work on those new files. so it looks like the only thing I can do is use the unlink() function which deletes the files fine. The only problem is now I have something like 100 sub directories all with files in them. I need to figure out a way to batch delete them. I can't find a script that goes through and finds all file contents including all sub directories and unlink those things. I found some that will use a for loop to list out the contents of a folder but it is just files. No sub directories. Any body got any ideas on which functions I should use or know where a script is that I can base mine off of. I am not sure how to approach this since what I tryed with chown and chmod has failed thus far. I currently have no code and am starting from scratch on this batch flushing of my directory.
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?
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??
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?
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?
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.
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.
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 ....
Breaking Up A Comma Seperated List
i have a list seperated by commas: 1. 3. 5. 7. 9 actually is a varible $members ="1, 3, 5, 7, 9"; what would be the best way to break that up to insert the values into a table in a loop.
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
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 )
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?
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
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.
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: ...
Comma Delimited Csv Has Commas Inside Fields
I need to import a CSV file into a database daily. That operation in itself is simple enough but the trouble is that some fields are quoted because they have commas inside them. How do I handle this with my import script? It would be much better if the CSV was created with all fields quoted or used a different delimited but sadly that is not an option.
Regular Expression For Comma-delimited Pairs
I have a textarea form field for inputting (or pasting) pairs of data. I need a regular expression pattern to validate each line for the following double quote number double quote comma double quote alpha string double quote carriage return The following comes close, but doesn't check for a carriage return at the end of each line: ^"([0-9]?)+"([,]s?"([A-Za-z0-9]+)")*$ For example the following would return true: "1","John" "2","Paul" "3","George" "4","Ringo"
Looping Thru Array And Creating Comma Sep String
I'm trying to loop through the elements of an array and create a comma separated string of the values, and then trim off the last comma. Here's the code I have which only displays the last element of the array in the string: PHP Code:
Stripping Quotes Out Of A Comma Delimited File?
I have a flat file that I'm trying to stick into a MySQL database. One record per line, multiple fields per record, and many of them are null fields which are just double quotes without a space between. It's probably nothing really major for people who have done this before, but I'm a bit stumped. The file is comma delimited. Every field is surrounded by double quotes. I've done quite a bit of searching, on the php site and elsewhere, but I can't seem to get it to strip the quotes out so I can explode the file line by line to grab the fields.
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
Seperate Links From Comma Seperated Value In A Databse
I have a value which is $keywords in my database The key words are separated by commas, like: fun, funny, exciting, weird I want to make each of those keywords link to "link.php" I can only get them all to be one link, how would I make them each into seperate links.
Easy Comma-delimited List To Dropdown Box Converter
I was working on a simple converter when I realized that by not setting the id param of the option tag, it wasn't going to send the value of the dropdown box to my php script. I had this to start with: Code:
How To Remove "comma, Full Stop" From A Sentence
I have sentences as follow: $quote[1] = "To be or not to be, that is the question."; $quote[2] = "Love looks not with the eyes, but with the mind."; $quote[3] = "Love all, trust a few. Do wrong to none."; now I would like to do the following, 1) for each quote[$i], remove all ","(comma) or "."(full stop)...does anyone know how? I have the following code but it does not work. What should I write in $patterns? for ($i=1; $i<4; $i++) { $quote[$i] = strtolower($quote[$i]); echo "$quote[$i]<BR>"; $pieces = explode(" ", $quote[$i]); for ($j=0; $j< (count($pieces)); $j++) { echo "$pieces[$j] "; $patterns = "."; $replacement = ""; print preg_replace($patterns, $replacement, $string); echo "$pieces[$j] <BR>"; } } 2) also, I would like to count a) number of frequecy of each term (e.g. "to" has a frequency of 2 in qoute[1]) and b) number of frequency for all three quotes (i.e. "to" has frequency = 3) but I have no idea how? can anyone please give me an idea?
Deleting
how could i delete everything from a table in a mysql db except for the 10 latest things ?
Deleting All Files
Is it possible to delete all files in a folder using unlink() or something similar?
Deleting The Saved Db The One Before?
I made a script that backups the database as sql file in the server. I mean script writes it into the harddrive, but everytime when i execute the script the harddrive loss another 3 mb. How can i modify the script to delete the one before when i execute it to write the new one?
Need Help With Deleting Records
I'm trying to add a link on the display of a record to delete that record. The main part of the record is stored in pw_event, then there are several rating fields for that record stored in pw_rate, and there is also several records for the first record stored in pw_whois. I need to have a link that will deleted everything for that record in all three tables. Here is my display script: PHP Code:
Deleting A Session
I want to be able to delete a session so that the next time there's a call to session_start, it creates a new session ID. I don't want to destroy the session variables specifically (though this will be a side-effect of what I'm doing) so I know that session_destroy isn't what I want to do. I presume I should just delete the session cookie manually. Is there a neater way? And if not, how do I do this?
Deleting A Director
I'm using this code trying to make ato delete a file or folder under w2k, apache. $direct=split("repadmin.php",$PATH_TRANSLATED); $file=$direct[0].$filedeleted; $filesys = eregi_replace("/","",$file); $delete = @chmod ($filesys, 0775); unlink("$delete"); header("Location:repadmin.php"); exit; but return this warning: Warning: unlink(1) [function.unlink]: No such file or directory in c:program filesapache groupapachehtdocsguonline epositorio epadmin.php on line 94 I checked the whole path and looks good.
Deleting Files
The below should delete files from a dir older than a week. I set the $dtime to 0 to test the script but it deletes nothing. What is wrong? Code:
Deleting Files
I'm using different files to store some arrays to make administration of a very small job-logger very easy. I currently read the file, remove the element to be deleted, delete the whole file, and write the file again without that element. Is there a way to remove a single element out of that file without deleting the whole file?
Deleting A Line
how do i delete from a text file 1 of the following lines jon|scott adam|smith <--delete paul|clark say i would like to delete the middle line of this txt, in member.txt what php code or logic would help me accomplish this? Also i am clicking on a hyperlink that is keeping count of the entries i have made. e.g php?record_id =1 php?record_id =2
Deleting A Record.
One last (hopefullly) problem I can't seem to get around for this program...why isn't this deleting the row i want? It does nothing. Now error messages either. HELP! $link = mysql_connect("localhost"); if(! $link) die("Could not connect to MySQL"); $database = "PC_Store"; mysql_select_db($database) or die ("could not open $database: ".mysql_error() ); $result = mysql_query("DELETE FROM inventorydata VALUES('$ProductID')"); The $ProductID variable is brought in from a menu choice on a diffrent page, it is also the primary of the table...so it should delete the whole row right?
Deleting Records
I've been trying to delete records since a week and i'm not able to do it. Before with this script, i was doing so many things at a time and i was confused.But, now, i just displaying the records from a table N trying to delete them.Would somebody pls guide me. I just wanna set the delete flag(i.e, i want to set the RBS_DELETE column to Y or something) when i check a check box to delete it. I've some 5 records displaying on my form and i want to check 3 of them and when i check them and hit submit, i want the RBS_DELETE column to have some value. PHP Code:
Deleting A Row From A Database
I can't fiqure out why my delete function isn't working. I have a listing of rows in my database with an option to delete an individual row at the end: Code:
Deleting A Message
I want a button to delete each message in you inbox wen clicked. im using this that doesn't work, because i coded it Code:
Cookie Not Deleting
login.php: setcookie('id', $userinfo['id'], time()+60*60*24*31*3 , '/'); logout.php: setcookie('id', '', time()-60*60*24*2); Any idea why it is not deleting my cookie?
Deleting Posts
How can I delete my previous post? It's showing up in Google when I search for the url referenced in my previous post (if I put the name here, it will show this post, too). If I can't delete it, can I make it so that Google can't pick it up?
Deleting Files
I'm trying to modify this script to remove files that end with %enlarged.jpg or %enlarged.gif or %enlarged.png, can someone help with the if statement, I've tried several things, of which, nothing is working: Code:
Deleting Folder
is there anyway of deleteing a folder and deleting all of its contents with it? i know that with rm_dir needs to folder to be emptied
Deleting The Pages!!!
I wanted the php files in my computer to be protected.If someone copies them and use in different machines,how can the php code find that the code is running in nextmachine. Is there any idea,that I delete the files using the unlink() method,when they are stored/run in next machine.
Deleting Using Checkboxes
im wanting to delete multiple things from a database using checkboxes, now i know how to use checkboxes in php etc. my question is would this be done using a basic while loop? i mean would i query all the things and then do while ($check_box == 'ON') { do the delete script } or is there something more to it?
Deleting A Line From.txt
it writes the line or lines to be deleted correctly into issues_deleted.txt which is line fwrite($file_contents_deleted, $value); and when it refreshes the line still exists in banip.txt it does echo out the line as well just doesnt remove it from banip.txt anyone know why? Code:
Deleting From Sql Database
I have used this script I made to delete files from a server and simultaneously remove information about the file from a database. I have uploaded the same script to a new website and it no longer works. The file does get deleted but the database line doesn't get removed. I can tell where it's going wrong by the error custom error message 'echo'ed on the page ("your file was only partially uploaded"), but I really don't know why.
Deleting Files
I have some script that takes an album id and deletes that album and the specific photos in that album. The code does run. The problem is that an error message i set to echo appears saying error deleting photo once the page automatically refreshes. When i check the image folder the images actually have been deleted. Code:
|