Hi,
I'm using a form to create an array and need to pass array to PHP to check if there is a matching field.
if($_POST['add']) {
...
$apple= $_POST['xxx'];
$oranges= $_POST['yyy'];
I create an array
$myarray = array("first => $apple","second => $oranges");
I read a file that contains similar entries as $myarray.
$row = 1;
$handle = fopen("file","r");
while(($data = fgetcsv($handle, 1000, " = ")) !== FALSE) {
...
I need to search through this array and alert if there's a match.
eg. if "$apple" exists in the file and also in $myarray.
I'm using foreach($myarray as $k => $v) {
...
but it looks like I get a value that is a concatenation of array elements not separated.
eg. first $apple second $oranges
How can I do this, please help.
array match problem
Moderator: General Moderators
-
madan koshti
- Forum Commoner
- Posts: 50
- Joined: Fri Jun 06, 2008 4:25 am
Re: array match problem
Hi,
$myarray = array("first => $apple","second => $oranges"); this will create an array like array ( [0] => first => apple [1] => second => oranges )
If you want array with keys 'first' and value as 'apple' then use this :
$myarray = array("first" => $apple,"second" => $oranges);
Hope it will be usefull .
$myarray = array("first => $apple","second => $oranges"); this will create an array like array ( [0] => first => apple [1] => second => oranges )
If you want array with keys 'first' and value as 'apple' then use this :
$myarray = array("first" => $apple,"second" => $oranges);
Hope it will be usefull .