PHP

How to join results with UNION in MySQL?

in

The UNIONs were introduced in MySQL 4. The unions are useful if you wish to join the results from more than one query, but be aware that the number of the returned columns by each select query should be the same.
(as well as their type)
 
The very simple example below show you the basics of the UNION statement
 
SELECT id, name FROM my_table
UNION
SELECT id, name FROM my_table;

Use regex (preg_match_all) to extract e-mail from a page

in

When parsing a site to harvest e-mail , we use Regex with preg_match_all() function to get all e-mail but the problem is that in some html,  user type email like that : abc @ gmail.com
 
How we solve this issue. Use this regex pattern:
 
$pattern="/([\s]*)([_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*([ ]+|)@([ ]+|)([a-zA-Z0-9-]+\.)+([a-zA-Z]{2,}))([\s]*)/i"; preg_match_all($pattern, $html_page, $matches);
 
That pattern will extract all type of email.

Syndicate content