Hello I have an array of data in the following format
The data contains address, phone numbers and some tags. There is a special Javascript value in the array within document.write, that when executed produce an email address. I want to save this data in a MySQL database using PHP, but with the actual email address not with the Javascript code and I am not able to figure out, how to do it ?
asked May 30, 2013 at 14:28
Vineet Sharma
8173 gold badges15 silver badges25 bronze badges
-
I'm assuming the pastebin represents HTML form data submitted to PHP. Can you post some information about the form itself, and about how it is generated? Parsing the string in PHP will work, but I think the real fix is to change whatever is putting Javascript code into a form input value, but we can't provide any pointers on that without this information.Scott S– Scott S2013年05月30日 14:47:15 +00:00Commented May 30, 2013 at 14:47
1 Answer 1
UPDATED
Send JS to the server then do
$decodedJS= html_entity_decode($myJS);
function extract_emails_from($string){
preg_match_all("/[\._a-zA-Z0-9-]+@[\._a-zA-Z0-9-]+/i", $string, $matches);
return $matches[0];
}
$email = extract_emails_from($decodedJS);
answered May 30, 2013 at 14:45
rinchik
2,6708 gold badges33 silver badges47 bronze badges
Sign up to request clarification or add additional context in comments.
1 Comment
Vineet Sharma
This worked great, here's the output pastebin.com/1D8TFcBY, Can you also tell me how can I extract the email addresses and other data from this multidimension array. The email is located at different indexed in the array :)
default