PHP regular internal chain exclusion alt method PHP now needs to implement the internal chain function, replace the keyword with the tag, but alt also has a keyword replacement, it will cause an error,
I want to replace the keywords in alt with
Php replaces the alt and title labels of the image. To replace all images or the connected alttitle, we must use the regular expression function. let's take a look at the alt instance * preg_replace (# alt [^] * # I, alt. $ title ., $ str); * to
Regular Expressions PHP
For PHP to filter the regular expression of ALT, Alt has three kinds of cases, the requirements can be filtered out
alt= "Xxxxxxxxxxxx"
alt= ' xxxxxxxxxxxx '
Alt=xxxxxxxxxxxx
Requirements can be filtered out of the above
Regular expression for filtering alt
Obtain the regular expression for filtering alt in PHP. alt can be filtered out in three cases.
Alt = "xxxxxxxxxxxx"
Alt = 'xxxxxxxxxxxxxxxx'
Alt = xxxxxxxxxxxx
You must be able to filter out the above three
To replace all the images or the alt title of the connection, we must use the regular function, see a replacement picture Alt instance
*/
preg_replace (' #alt = ' [^ ']* ' #i ', ' alt= ' ". $title." ", $str);
/*Mixed preg_replace (mixed
Example
$arcrow [' title ']= ' article titles ';$arcrow [' content ']= ' article body ';
$pattern = "/(]*?alt=[^<>]*?>)) (.*?>)/is "; Add an alt label to a picture$replacement = "\$1 alt= '". Strip_tags ($arcrow [' title ']). "' \$2";$arcrow ['
WordPress uses Gravatar as the reviewer's profile picture, which should be well known. However, we do not know whether we have found that the Alt attribute of the Gravatar Avatar is null, which obviously does not comply with w3c standards. Zhou
1 origin
With regard to PHP, many people intuitively feel that PHP is a flexible scripting language with rich library classes, simple to use, and secure. It is very suitable for WEB development, but its performance is low. Is PHP performance really
To replace all images or the connected alt title, we must use the regular function. Let's look at an alt instance that replaces the image.*/Preg_replace ('# alt = "[^"] * "# I', 'alt =" ". $ title." "', $ str );/*Mixed preg_replace (mixed pattern,
Specific operation:1. Preparatory workIn order to avoid the occurrence of program conflicts, it is recommended to first uninstall the RPM-installed PHP and related dependencies (if any).650) this.width=650; "Style="
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.