0

I'm having a simple issue that I've been beating my head against the screen trying to figure out. I have a variable $sceneArray that holds the array listed below. I also have another variable $locateRecord that holds something like ['opening']['scene2'].

Ordinarily, to get the value of scene2, I would just reference $sceneArray['opening']['scene2']. But in this case, I need to combine the two variables to retrieve that value. I have tried things like ${sceneArray.$locateRecord} but that isn't work for me either.

Would appreciate any hint!

EDIT: I have the ability to format the $locateRecord value in a different way if that can solve this. For example, I could structure it as opening>scene2 or opening,scene2 etc.

Array
(
  [opening] => Array
    (
      [scene1] => 1:00
      [scene2] => 2:00
    )

  [closing] => Array
    (
      [scene3] => 3:00
      [scene4] => 4:00
    )
)
5
  • What do you get? Do you get an error? If you get an error can you please post it :D Commented Jan 27, 2021 at 17:48
  • There are many questions on this site that deal with a similar issue. That should get you started on the right path. Commented Jan 27, 2021 at 17:50
  • @NathanielEskenazi Thank you for the reply! No error - just an empty value. Commented Jan 27, 2021 at 17:51
  • eval is the first thing that comes to mind. But there will be a bunch of people who don't like it. Can you afford, memory-wise, to build another data structure where ['opening---scene2'] is present? Commented Jan 27, 2021 at 17:52
  • @El_Vanja Thank you for the links. I've tried those approaches and, unfortunately, still not having any luck. Commented Jan 27, 2021 at 18:47

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.