Q:

Write a PHP script to extract text (within parenthesis) from a string

0

Write a PHP script to extract text (within parenthesis) from a string.

Sample strings : 'The quick brown [fox].'

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

<?php
$my_text = 'The quick brown [fox].';
preg_match('#\[(.*?)\]#', $my_text, $match);
print $match[1]."\n";
?>

Sample Output:

fox

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now