currently I am working on a username checker. I am trying to get all the available usernames to echo into a textarea, the only problem is that because the textarea is within a function and an 'if' statement, instead of the code displaying all available usernames into 1 single text area, because the textarea is inside the function and 'if' statement, the textarea continues to produce with every username checked.
Live example of the problem: http://hawkgen.com/ogpost/
Code: (second textarea is the one producing the problem)
<?php
function getTitle($Url){
$str = file_get_contents($Url);
if(strlen($str)>0){
preg_match("/\<title\>(.*)\<\/title\>/",$str,$title);
return $title[1];
}
else
return '404';
}
?>
<form action="index.php" method="post">
<textarea name="notes" value="username" rows="4" cols="50">
test
test1
test2
test3
test4
test5
</textarea>
<input type="submit" value="Submit">
</form>
<?php
$convert = explode("\r\n", $_POST["notes"]);
for ($i=0;$i<count($convert);$i++)
{
if (strlen($convert[$i])>0) {
$resultCheck = getTitle("http://www.youtube.com/" . $convert[$i]);
if (strpos($resultCheck,'404') !== false) {
?>
<textarea id="myText" rows="10" cols="40">
<?php
echo $convert[$i];
echo "\n";
?>
</textarea>
<?php
}
else {
}
}
}
?>