do you know how to test, whether an index, based on what we pass in a string, exists in an array?
Assume the following code:
<?php
$myArray = [
"elemOne" => "valueElemOne",
"elemTwo" => [
"elemTwoOne" => "valueElemTwoOne",
"elemTwoTwo" => [
"elemThreeOne" => "valueElemThreeOne",
"elemThreeTwo" => "valueElemThreeTwo",
],
],
];
Now, I have a string $myString = "elemTwo/elemTwoTwo/elemThreeThree". What I want to do with $myString is somewhat format it in a way, so I could check
<?php
if(isset($myArray['elemTwo']['elemTwoTwo']['elemThreeThree'])) {
// maybe do something
return true;
} else {
return false;
}
Naturally in my case this would return false, as the index "elemThreeThree" does not exist within my array. I tried splitting the string, tried to format as [elemTwo][elemTwoTwo][elemThreeThree] and then evaluating it, but nothing really worked.
Do you think of a possible approach that could help me?