Array help, looping through array to check for content.
Posted: Wed Oct 04, 2006 9:45 am
I am trying to help a user on here, I've made this array, and a function that takes the value of $_POST['name'] and checks to see if it exists within an array. Somewhere along the line I am screwing up. As I said this is for someone else, just trying to help
test1_array.php
the form
test1_array.php
Code: Select all
<?php
error_reporting(E_ALL);
ini_set('display_errors', true);
ini_set('html_errors', false);
$users_array = array(
'bob',
'lisa'
);
function users_array() {
$value = $_POST['name'];
if (!is_array($users_array)) {
echo "this is not an array";
return false;
} else {
while (in_array($value)) {
echo "user found";
break;
return true;
}
echo "you're not in there";
break;
return false;
}
return users_array();
}
?>Code: Select all
<form method="POST" action="test1_array.php">
<h1>your name </h1>
<input type="text" name="name">
<input type="submit" value="submit this" name="submit">
</form>