Php? Remove space-php Tutorial

Source: Internet
Author: User
Php? Remove spaces
[Content_ SC] => name of the trade name (Chinese): name of the Company Limited (English): Address of the trade name: Guangzhou operating Project: gold coins, coins, banknotes, stamps, interesting products, tea contact name (Chinese): Zhang San contact name (English): phone 123232328899 Fax: QQ23232370566 Web site: Email: 532326603@99.com $ row ['content _ tc '] = str_replace ('', '', $ row ['content _ tc ']); I use str_replace to replace spaces. However, there is nothing to do with the desired effect [content_ SC] => name of the firm (Chinese ): company name (English): Address: Guangzhou operating Project: gold coins, coins, banknotes, stamps, interesting products, tea contact name (Chinese): name of Michael Zhang contact (English ): phone: 123232328899 Fax: QQ23232370566 Web site: Email: 532326603@99.com



Reply to discussion (solution)

$ S = <TXT name (Chinese): name of the Company Limited (English): Address of the business name: Guangzhou operating Project: gold coins, coins, banknotes, stamps, interesting products, tea contact name (Chinese): Zhang San contact name (English): phone 123232328899 Fax: QQ23232370566 Web site: Email: 532326603@99.comTXT; echo preg_replace ("/[\ t] + /", '', $ s );
Name of the trade name (Chinese): name of the Company Limited (English): Address of the trade name: Guangzhou operating Project: gold coins, coins, banknotes, stamps, interesting products, name of the contact person for tea products (Chinese ): name of contact person (English): phone 123232328899 Fax: QQ23232370566 Web site: Email: 532326603@99.com

Yes
Str_replace ('','', $ row ['content _ tc ']);
Note that the first space is a special symbol.



 
 


Do not wrap


 

Of course, line breaks are not supported in html mode!

Do not wrap

Of course, line breaks are not supported in html mode!
You can view the source code in the browser.

Do not wrap




Preg_replace ("/[\ t] +/", '', $ row ['content _ tc ']); add this sentence to show the same effect as the original one.

I want to remove spaces and keep the line feed when displaying them.

$ Row ['content _ tc '] = preg_replace ("/[\ t] +/", '', $ row ['content _ tc']);

Are you stupid to make any mistakes?




$ Row ['content _ tc '] = preg_replace ("/[\ t] +/", '', $ row ['content _ tc']);
No line breaks

Only text line breaks are in your data, while html line breaks are

Are you sure you want to forget this?


Baidu replaced the text line break


$row['content_tc']=preg_replace("/\r\n/", '
',$row['content_tc']);

The results won't work. it's messy in an instant ........

Can I post your code? I feel that your order is wrong.

Can I post your code? It seems that your order is wrong.


 foreach ($information as $row) {                $row['content_tc']=preg_replace("/[ \t]+/", '',$row['content_tc']);        $row['content_tc']=preg_replace("/\r\n/", '
',$row['content_tc']); } $informationAfterHandle[] = $row;

I cannot change the order.

foreach ($information as $row) {               $row['content_tc']=preg_replace("/\r\n/", '
',$row['content_tc']); $row['content_tc']=preg_replace("/[ \t]+/", '',$row['content_tc']); } $informationAfterHandle[] = $row;

foreach ($information as $row) {                $row['content_tc']=preg_replace("/[ \t]+/", '',$row['content_tc']);        $row['content_tc']=nl2br($row['content_tc']);        $informationAfterHandle[] = $row;}

foreach ($information as $row) {                $row['content_tc']=preg_replace("/[ \t]+/", '',$row['content_tc']);        $row['content_tc']=nl2br($row['content_tc']);        $informationAfterHandle[] = $row;}



Messy after adding

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.