OK - Here is what I am trying to accomplish.
I have an html file on my server.
I have loaded the contents of that file into a variable called $contents.
I now want to look at that string and find each occurrence of a particular group of characters and extract that group of characters.
Example :
<a onclick='modal_maptile(539396,"null",745,745,"null","null",null,"null","null",null,24,"bcity","null",6,null,null,null);return false;
- What I want to do is extract everything that is between this >> maptile( and this >> );return false
The contents between will be different most of the time. but there will be about 100 of these onclick instances in the file/string.
Of course I want to dump each field (separated by the comma) into an array.
After I do this step, then there is more I will need to do, but this is where I am stuck right now.
Thanks!
Specialized Search requirement - need help figuring out
Moderator: General Moderators
- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
Re: Specialized Search requirement - need help figuring out
Check the documentation for preg_match(). There should be plenty of examples there.
(#10850)
- AbraCadaver
- DevNet Master
- Posts: 2572
- Joined: Mon Feb 24, 2003 10:12 am
- Location: The Republic of Texas
- Contact:
Re: Specialized Search requirement - need help figuring out
This should do it for any onclick:
If you want only the modal_maptile onclicks then:
Code: Select all
preg_match_all('/onclick=[^\(]*\(([^\)]*)\)/i', $content, $matches);Code: Select all
preg_match_all("/onclick='modal_maptile\(([^\)]*)\)/i", $content, $matches); mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
Re: Specialized Search requirement - need help figuring out
Great start folks! I do appreciate it.
BTW - I found this just this morning: http://www.webcheatsheet.com/php/regula ... ssions.php
I will try some of these and get back to you here and let you know where I am at.
BTW - I found this just this morning: http://www.webcheatsheet.com/php/regula ... ssions.php
I will try some of these and get back to you here and let you know where I am at.