PHP array problem array
$ Id = array ('AAA', 'BBB'); // This array can be used properly. If (in_array ($ url, $ id) // you can determine whether it is normal. // However, my current array is uncertain, not necessarily "aaa", "bbb ", $ idtxt = "'AAA', 'BBB, 'CCC '" will be added with the addition of another function $ idtxt. // it will be added frequently here, how can I write the following array to call this? $ Id = array ($ idtxt); // for example, if I write like this, the following judgment is not normal. how can I write it ?? If (in_array ($ url, $ id) // The result is not true.
What should I do ??
Reply to discussion (solution)
First, you violate the rules!
$ Id = array ('AAA', 'BBB ');
If (in_array ($ url, $ id ))
This is correct.
$ Id [] = 'CCC ';
If (in_array ($ url, $ id ))
This is still true.
While
$ Idtxt = "'AAA', 'BBB ', 'CCC '";
$ Vip = array ($ idtxt );
You can print out $ vip to find out why it is wrong.
First, you violate the rules!
$ Id = array ('AAA', 'BBB ');
If (in_array ($ url, $ id ))
This is correct.
$ Id [] = 'CCC ';
If (in_array ($ url, $ id ))
This is still true.
While
$ Idtxt = "'AAA', 'BBB ', 'CCC '";
$ Vip = array ($ idtxt );
You can print out $ vip to find out why it is wrong.
Well .. I know it is wrong... I mean, I wrote an error, but how can I write it to achieve what I want...
Format: $ id [] = 'CCC ';
$ Id = split (',', $ idtxt );
$ Id = split (',', $ idtxt );
$ Id = split (',', $ idtxt );
Print_r ($ vip); // This is the case. it is correct when $ id is output, but the following statements are still not normal. do you need to write other statements?
If (in_array ($ url, $ id ))
$ Id = split (',', $ idtxt );
Yes .. Wrong .. Thank you.