php - finding and storing values from string -


I have a string that looks something like this:

  $ fetched = Name = myName zip = 420424 country = myCountry;  

I only want zip = 8732 9 (only numbers), this is not an array

.

Then I use it:

  $ $ $ The function that is returned above is the output of the function given below $ fetched = file_get_contents ("http: // example. Com ");  

In this way I can fetch the content and match it with this code

  $ zip = preg_match ('/ zip = [0-9] ] + / ', Received $);  

But I want to store it in the variable, what is the function to match the result?

You need to point to the part that you want to capture with the parentheses, then these To select, provide an extra parameter for preg_match:

  $ matches = array (); If (preg_match ('/ zip = ([0-9] +) /', $ obtained, $ match) {$ zip = $ matches [1];}  

Comments

Popular posts from this blog

c++ - Linux and clipboard -

What is expire header and how to achive them in ASP.NET and PHP? -

sql server - How can I determine which of my SQL 2005 statistics are unused? -