-
-
- /**
- * Read configuration file
- * edit: WWW.JBXUE.COM
- */
- $encodename='Existing characters';
- $lines = @file('ske.txt');
- var_export($lines);
- if(in_array($encodename,$lines))
- //The judgment here fails because: the array read by file contains a number change symbol.
Copy code
Solution:
-
-
- $lines =array_map('rtrim',file('ske.txt'));
- var_export($lines);
-
- if(in_array($encodename,$lines))
- //--The judgment here is successful
Copy the code
Attached is the usage of the array_map() function:
arrayarray_map( callback callback, array arr1 [, array ...] )
array_map() returns an array that contains all the cells in arr1 after the callback has been applied.
The number of arguments accepted by the callback should be consistent with the number of arrays passed to the array_map() function.
|