I am new to PHP. I need help to open file and find a line within double quotes after known word(namespace) and store it in another variable. The line after the word may be after a space or may be in the next line. Here is my code.
$string = 'namespace
"urn:fsd:fsdf:fdsfs"';
if (preg_match('/namespace *"([^"]+)"/', $string, $m)) {
echo $m[1];
}
This displays null.
Sample input:
$string = 'namespace
"urn:fsd:fsdf:fdsfs"';
Output should be:
urn:fsd:fsdf:fdsfs
I am not getting the value i.e. urn:fsd:fsdf:fdsfs. I get a null. If the input is in the same line as below :
$string = 'namespace "urn:fsd:fsdf:fdsfs"';
I get output. But if it is in next line null is displayed.