I am trying to create an array to store which nodes I have visited before. The nodes will be uniquely represented by a string, and the string can be very long. Hence, I am wondering which of the two implementations will be faster or more scalable.
$stateString = "..... ....";
$states = array();
1) Storing the stateString as a key
$states[$stateString] = true; // I just want to set the key in the array
$visited = isset($states[$stateString]);
2) Storing the stateString as a value
$states[] = $stateString;
$visited = in_array($stateString, $states);