gstalin
asked on
Get contents from text file
Hi Guys,
I have the text file which have the contents given below.
"<text title1="Training Area" title2="Test">
<p align="left"><b>HTML</b> Content for the training.<br>
This area will be filled with HTML source code to be displayed into the page.
</text>"
I want to get the contents only the attribute values of 'title1' and 'title2' in the text tag.
How to get this? Please provide me the solution for this.
I have the text file which have the contents given below.
"<text title1="Training Area" title2="Test">
<p align="left"><b>HTML</b> Content for the training.<br>
This area will be filled with HTML source code to be displayed into the page.
</text>"
I want to get the contents only the attribute values of 'title1' and 'title2' in the text tag.
How to get this? Please provide me the solution for this.
Very bad solution. If you want try this
$title2 = '';
$arr=explode("title1=\"",$ str);
$arr=explode("\"",$arr[1]) ;
$title1=$arr[0];
$arr=explode("title2=\"",$ str);
$arr=explode("\"",$arr[1]) ;
$title2=$arr[0];
echo "<br>title1=".$title1;
echo "<br>title2=".$title2;
$title2 = '';
$arr=explode("title1=\"",$
$arr=explode("\"",$arr[1])
$title1=$arr[0];
$arr=explode("title2=\"",$
$arr=explode("\"",$arr[1])
$title2=$arr[0];
echo "<br>title1=".$title1;
echo "<br>title2=".$title2;
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
If you want to use preg_match you can use:
$title1 = '';
$title2 = '';
if(preg_match_all('/(title
foreach($results[0] as $key => $value) {
if($results[1][$key] == 'title1') $title1 = $results[2][$key];
if($results[1][$key] == 'title2') $title2 = $results[2][$key];
}
}
-r-