Jump to content

[SOLVED] How would I do this?


Unseeeen

Recommended Posts

Thanks guys, that helps a lot. Here's my code...

 

<form action="" method="post">
<textarea name="first"></textarea><br>
<textarea name="second"></textarea>
<input value="Submit" type="submit">

</form>
<?
$first = $_POST['first'];
$second = $_POST['second'];


$blah = explode(" ", $first);
$blahtwo = explode(" ", $second);

$result = array_intersect($blah, $blahtwo);
print_r($result);
?> 

 

It's simple, the way I like it. Anyways, how would I echo the info without having that "Array ( [0] => joe )" thing at the end?

first use

$x=count($result); this count how many matches found

then loop

for($i=0; $1<$x; $i++)

{

    echo $result[$i];// assign in the variable

}

 

but if your sure that there will only be one match

echo $result[0]; this is how to replace the print_r

<form action="" method="post">
<textarea name="first"></textarea><br>
<textarea name="second"></textarea>
<input value="Submit" type="submit">

</form>
<?
$first = $_POST['first'];
$second = $_POST['second'];
$blah = explode(" ", $first);
$blahtwo = explode(" ", $second);

$result = array_intersect($blah, $blahtwo);
for($i=0; $i<count($result); $i++)
{
    echo $result[$i];// assign in the variable
}

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.