A common problem which we encounter during string processing
In the program a sentence is given which contains actual text enclosed in parenthesis. In that case to extract only those text, we can go for the below given code. The same would be of great use in pdf text extraction.
<?php
$text="1212(HI)fjsdlf(how)sldfjs(are)sldfjslf(you)";
preg_match_all('#\((.*?)\)#', $text, $match);
print_r ($match);
$key=key($match);
$val=$match[$key];
if ($val<> ' ')
{
echo $key ." = ". $val ." <br> ";
for ($i1 = 0; $i1 < count($val); $i1++)
{ echo "entered";
$key1=key($val);
$val1=$val[$key1];
if ($val1<> ' ')
{
echo "--". $key1 ." = ". $val1 ." <br> ";
}
next($val);
}
}
?>
In the program a sentence is given which contains actual text enclosed in parenthesis. In that case to extract only those text, we can go for the below given code. The same would be of great use in pdf text extraction.
<?php
$text="1212(HI)fjsdlf(how)sldfjs(are)sldfjslf(you)";
preg_match_all('#\((.*?)\)#', $text, $match);
print_r ($match);
$key=key($match);
$val=$match[$key];
if ($val<> ' ')
{
echo $key ." = ". $val ." <br> ";
for ($i1 = 0; $i1 < count($val); $i1++)
{ echo "entered";
$key1=key($val);
$val1=$val[$key1];
if ($val1<> ' ')
{
echo "--". $key1 ." = ". $val1 ." <br> ";
}
next($val);
}
}
?>
No comments:
Post a Comment