Today, when collecting images from the Momo website, the resolution of the images will be changed to 320*480, and the original images contain pixel information.
For example, clear cottage (320*480) Wallpaper
So what should I do if I want to leave the "Clear cottage Wallpaper?
First, we should immediately think that we should first find the string and remove it.
Well, first of all, I thought so too. I defined an array and saved several strings, such as (320*480) and (480*640). But later I found that, if there are other types of stream (320*234), it is not impossible for me to list them all, but it is just a matter of time. But we don't want to do this. It's boring. It is estimated that half a day has passed, and it is quite uncomfortable.
So what should we do?
First, observe multiple pieces of data. We found that there should be "*", which must be known. Otherwise, the values that do not have to be included will increase the workload of the computer.
Here comes:
[Php]
If (strchr ($ title ,"*"))
{
Used to determine whether a string contains "*";
If so, there must be something we want to remove. What should we do next? Find the string to be removed and replace it with NULL? Obviously, you cannot find it in the way above.
I used the string cutting method:
[Php]
$ Arr = split ('([\ (] *) [0-9] + \ * [0-9] + ([\)] *)', $ title ); // * Be sure to escape
$ Title = $ arr [0]. $ arr [1];
([\ (] *) [0-9] + X [0-9] + ([\)] *) is a regular expression,
([\ (] *) Indicates that there may be (
[0-9] + indicates that at least one number from 0 to 9 exists.
[Php]
"*"
So the above (320*480) is easy to find.
Here is the test program.
[Php]
<Pre name = "code" class = "php"> <? Php
$ Title = "Clear hut (320*480) Wallpaper ";
If (strchr ($ title ,"*"))
{
$ Arr = split ('([\ (] *) [0-9] + \ * [0-9] + ([\)] *)', $ title ); // * Be sure to escape
$ Title = $ arr [0]. $ arr [1];
Echo $ title;
}
?>
Author: wolinxuebin