Hi all,
I am trying to search and array (neat) based on the key of another array (data)
They both have identical key values but the content differs.
I am basically trying to display errors for missing fields and want to be able to display what is missing in a neater way.
However I am not getting any results?
<?php
$data = [
'keyone' => $_POST['myvalue'],
'keytwo' => $_POST['myothervalue'],
];
$neat= [
'keyone' => 'My Value',
'keytwo' => 'My Other Value',
];
foreach ($data as $key=>$value) {
if($value == ''){
$neatdisp = array_search($key, $neat);
echo ' My Neat Display is: '.$neatdisp.'<br/>';
//this should display the following
// if the $_POST values are empty
/////////////////////////////////
//My Neat Display is: My Value
//My Neat Display is: My Other Value
//////////////////////////////////
// what it is display when I test
//My Neat Display is:
//My Neat Display is:
/////////////////////////////////
} else {}
}
?>
Wha'ts the best way for me to approach this?