如何使用PHP数组实现这一点?

如何使用PHP数组实现这一点?,php,arrays,Php,Arrays,然后在表格上我会有这样的东西 $signup_errors['captcha'] = 'Please enter the correct security code'; 好的,我想我明白了,php键exist似乎起到了作用 <input type="text" class="textarealong <?PHP if (isset($signup_errors) && in_array('captcha', $signup_errors)){echo 'error-

然后在表格上我会有这样的东西

$signup_errors['captcha'] = 'Please enter the correct security code';

好的,我想我明白了,php键exist似乎起到了作用

<input type="text" class="textarealong <?PHP if (isset($signup_errors) && in_array('captcha', $signup_errors)){echo 'error-class';}?> " value=''>

好的,我想我明白了,php键exist似乎起到了作用

<input type="text" class="textarealong <?PHP if (isset($signup_errors) && in_array('captcha', $signup_errors)){echo 'error-class';}?> " value=''>
使用

使用

在你的情况下,我会使用

<input type="text" class="textarealong <?PHP if (isset($signup_errors) && array_key_exists('captcha', $signup_errors)){echo 'error-class';}?> " value=''>
而不是

isset($search_array['first']);
对我来说,它可能更快、更可读。

在你的情况下,我会使用

<input type="text" class="textarealong <?PHP if (isset($signup_errors) && array_key_exists('captcha', $signup_errors)){echo 'error-class';}?> " value=''>
而不是

isset($search_array['first']);
对我来说,它可能更快更可读