i was wondering what was the best option to store a string in an array.
let me explain: I only need one part of the elements in the array. i.e. i can use the key to store my string, or i can use the value to store the string.
I'll make it clearer with some code:
Expand|Select|Wrap|Line Numbers
- $string = 'someString';
- $array = array();
- //first way to save
- $array[$string] = true;//array('someString' => true)
- //second way to save
- $array[] = $string; //array(0 => 'someString')
maybe how i will use that array helps:
I will need to know afterwards, if the string is stored in the array.
Expand|Select|Wrap|Line Numbers
- //i get a string and i want to know if it is already in array
- in_array($string, $array);
- isset($array[$string]);
- ...
thanks!