The solution to the problem that cf cannot be full screen in win7. The method of string replacement in php

WBOY
Release: 2016-07-29 08:47:43
Original
1164 people have browsed it

In the past few days, I encountered a small problem at work. There is a content type field that stores language. Because the data is imported from Excel, so in order to simplify the processing, many languages ​​​​are separated by commas, and all languages ​​​​are A string, which makes saving it much simpler. However, due to the problem of data quality at the beginning, some "Chinese" was "Mandarin Chinese". Now it is necessary to change all "Mandarin Chinese" to "Chinese".
This requires replacing part of a string. For such a problem, we usually use regular expressions to do the replacement, or use some replacement methods in PHP. It feels very troublesome to do this, and time is tight, so I thought of a lazy way, using the explode function. , use the string to be replaced as the delimiter, then connect the string to be replaced between the two array elements, and then UPDATE.

Copy code 如 Code as follows: & lt;? Php Function Replace () {

$ SQL = DB_QUERY ("Select Field_languages_value, nid from {Content_company_profile} E

field_languages_value like '%mandarin Chinese%' " );
while($result = db_fetch_object($sql)){
$a = explode("Mandarin Chinese",$result->field_languages_used_value);
$b = $a[].'Chinese'.$a[ 1];
db_query("UPDATE content_type_company_profile SET field_languages_used_value = '%s' WHERE nid = %
d",$b,$result->nid);
}
}
?>


The above introduces the solution to the problem that cf cannot full screen win7 and the PHP string replacement method, including the content of the solution to the problem that cf cannot full screen win7. I hope it will be helpful to friends who are interested in PHP tutorials.

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!