I'm relatively new to PHP and I'm currently working on a project where I need to create a PHP variable from a string. I've searched extensively but couldn't find a clear answer, so I thought I'd ask here for some guidance.
Here's my scenario: I have a string, let's say "$nameString", that holds a value like "John Doe". What I want to do is create a PHP variable, let's say "$name", and assign the value "John Doe" to it. Essentially, I want to extract the value from the string and store it in a variable.
I've tried a few things, like using the "eval()" function, but it didn't work as expected. Maybe I'm missing something or there's a better approach to achieve this. Could someone shed some light on how to accomplish this task?
Any help or suggestions would be greatly appreciated. Thanks in advance!