Get the App
SLTechnology News&Howtos  ›  Development  › 

How php replaces nbsp spaces

Shulou Source: shulou.com Published: 2022-05-31 19:48:08 11月12日 Update

In this article Xiaobian for you to introduce in detail "php how to replace nbsp spaces", the content is detailed, the steps are clear, the details are handled properly, I hope this "php how to replace nbsp spaces" article can help you solve your doubts, the following follow the editor's ideas slowly in-depth, together to learn new knowledge.

Methods: 1. Use the "str_replace (", "other characters", $str) statement to replace the nbsp character with other characters; 2, use the "preg_replace (" / (\ s |\ & nbsp\; | |\ xc2\ xa0) / "," other characters, $str) "statement.

Operating environment of this tutorial: windows7 system, PHP7.1 version, DELL G3 computer

Nbsp space character

In HTML, it is a space entity, also known as non-wrapping spaces, is the most common and we use the most frequently used spaces, most people may only touch, it is the space generated by pressing the space key. In HTML, if you use the spacebar to generate this space, the spaces will not accumulate (only 1). Html entity representation is required before it can be added

The width occupied by the space is obviously and strongly affected by the font.

How does php replace nbsp spaces

Method 1: use the str_replaceh () function

Use str_replaceh () to search for the "" substring and replace it with other characters, such as null characters.

Method 2: use the preg_replace () function and regular expressions

Use regular expressions to search for all "" in the string and replace it with other characters, such as the empty character''.

Regular expression used: / (\ s |\ & nbsp\; | |\ xc2\ xa0) /

Read here, this "php how to replace nbsp spaces" article has been introduced, want to master the knowledge of this article also need to practice and use in order to understand, if you want to know more related articles, welcome to follow the industry information channel.

Tags: Space character space character article method regular expression Chinese net content function entity empty character sentence Chinese and will search proper obvious also known as font Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Apple Shulou Information Linux Huawei MariaDB