I have a form in which will be inserted text with the web addresses. And i already have regular expression validation rule t search for web address. This rule will replace web links to another text. But my task is to write a function for saving all of this addresses to array. How can i save all of this addresses to array?
This is my code that i have for now:
<html>
<head>
<meta charset="UTF-8">
<title>Expressions: Find web address in text</title>
</head>
<body>
<?php
/*--------Functions---------*/
function webCheck($webtext){
global $web_check;
$web_check = "/((http:\/\/www\.)|(http:\/\/)|(www\.))([a-z0-9]+([a-z0-9-]*[a-z0-9]+)*\.)+[a-z]+/i";
return preg_replace($web_check, "<b>was weblink here</b>", $webtext);
}
/*--------End of Functions----------*/
if(isset($_POST["webadd"])){
$webtext = $_POST["webtext"];
if (!empty($webtext)){
echo webCheck($webtext);
}else{
echo "Feald cannot be empty. Please enter some text.";
}
} else {
echo "Please enter text in text area.";
}
?>
<form action="expression3.php" method="POST">
<table>
<tr>
<td>Find web address in text</td>
</tr>
<tr>
<td> <textarea name="webtext" cols="50" rows="10"></textarea></td>
</tr>
<tr>
<td><input type="submit" name="webadd" value="Find Web Address!" /></td>
</tr>
</table>
</form>
</body>