PHP problem. What happens when we remove blank spaces are many, between two words. Remove linebreaks
By definition, the functions that eliminate blank spaces in php, you can do at the beginning of the string, the end or the beginning and end simultaneously.
But there is no function to remove extra spaces (more than one) between two words. The solution provided for this is using regular expressions.
The credits are for Xanders of www.infrabios.com
$ long_description = preg_replace ("/ +/","", $ long_description);
This returns the string without the extra spaces between words.
Xanders Thanks!
Slds;)
Guille
Tuesday, October 27, 2009
Jewel De'nyle Shelly Martinez
The problem to solve was to remove line breaks from a description, when exporting a table. The specific problem was that it appeared the newline character in the description (that sort of inverted P).
not work with trim, did not work with str_replace, only worked with the following solution provided by Christ, in web forums.
What it does basically, is trying to replace any of the combinations, with precisely nothing.
Crista: Mil Gracias!
$ replaced = array ( "\\ r \\ n" , "\\ n \\ r" , "\\ n" , "\\ r " )
$ content = str_replace ( $ replaced , " , $ content);
Slds;)
Guille
Monday, October 26, 2009
Good Shortwave Base Station
Writing a line break in csv file. Curiosities of MSN today
Dear: What you should
be very simple, it is sometimes still quite complicated, not for lack of knowledge but for lack of documentation.
When we import data from a query in a csv file, and wish to incorporate the line break at the end of it, we must encode it as follows. (I summarized quite the example in line fwrite, you might as well write the string they want and make an append to the end of this.)
fwrite ($ fp, chr (13). Chr (10)); (Where $ fp contains the file pointer, and chr (13). Chr (10) is equivalent to \\ r \\ n.)
I hope you learn, cheers! Guille
Dear: What you should
be very simple, it is sometimes still quite complicated, not for lack of knowledge but for lack of documentation.
When we import data from a query in a csv file, and wish to incorporate the line break at the end of it, we must encode it as follows. (I summarized quite the example in line fwrite, you might as well write the string they want and make an append to the end of this.)
fwrite ($ fp, chr (13). Chr (10)); (Where $ fp contains the file pointer, and chr (13). Chr (10) is equivalent to \\ r \\ n.)
I hope you learn, cheers! Guille
Subscribe to:
Posts (Atom)