Want to check if value exist in array in WordPress, then you can use array_map php function instead of foreach loop, then use in_array to find value.
1 2 3 4 5 6 7 8 9 10 | $login = $wpdb->get_results( "SELECT kunde FROM wp_kundenumber", ARRAY_N ); $dataArray = array_map(function ($arr) {return $arr[0];}, $login); //will return single dimentional array of value at 0 index in $login items if(in_array($kunde_string, $dataArray)) ///then in_array will work for you.. to find $kunde_string { echo "Succes"; } else { echo "Failure"; } |
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.