Capturing and analyzing a file is very simple. This tutorial will show you how to implement it step by step through an example. Let's get started! First, I must first determine the URL we will capture. It can be set in the script or passed through $ QUERY_STRING. For simplicity, let's change SyntaxHighlighter. all ();
Capturing and analyzing a file is very simple. This tutorial will show you how to implement it step by step through an example. Let's get started!
First, I must first determine the URL we will capture. It can be set in the script or passed through $ QUERY_STRING. For simplicity
For the sake of simplicity, let's set the variables directly in the script.
$ Url = http://www.php.net;
?>
Step 2: capture the specified file and store it in an array using the file () function.
$ Url = http://www.php.net;
$ Lines_array = file ($ url );
?>
Now the file is available in the array. However, the text we want to analyze may not be all in one line. To solve this problem, we can simply convert the array $ lines_array into a string. We can use the implode (x, y) function to implement it. If you want to use explode (array of string variables), set x to "|" or "! "Or other similar separators may be better. But for our purpose, it is best to set x to a space. Y is another necessary parameter because it is an array that you want to process with implode.
$ Url = http://www.php.net;
$ Lines_array = file ($ url );
$ Lines_string = implode (, $ lines_array );
?>
Now, the crawling is finished, and the analysis is as follows. For the purpose of this example, we wantToBetween all things. To analyze the string, we also need something called a regular expression.
$ Url = http://www.php.net;
$ Lines_array = file ($ url );
$ Lines_string = implode (, $ lines_array );
Eregi ("(.*)", $ Lines_string, $ head );
?>
Let's take a look at the code. As you can see, the eregi () function is executed in the following format:
Eregi ("(.*)", $ Lines_string, $ head );
"(. *)" Indicates everything, which can be interpreted as, "analysis inAnd". $ Lines_string is the string we are analyzing, and $ head is the array of the analysis result.
Finally, we can lose data. Because onlyAndThere is an instance between them. we can safely assume that only one element exists in the array, which is what we want. Let's print it out.
$ Url = http://www.php.net;
$ Lines_array = file ($ url );
$ Lines_string = implode (, $ lines_array );
Eregi ("(.*)", $ Lines_string, $ head );
Echo $ head [0];
?>
This is all the code.