Jump to content

NavCrowds

New Members
  • Posts

    1
  • Joined

  • Last visited

NavCrowds's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. 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?
×
×
  • 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.