[ create a new paste ] login | about

Link: http://codepad.org/oAP5BqSm    [ raw code | output | fork ]

PHP, pasted on Feb 22:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
<?php

    $html = '<p><img src="story_img.jpg" width=120 height=80>In the last couple of weeks I often had to download a lot of files, submitted to a web-based teaching platform. Downloading all these files by hand is very annoying so I implemented a short Groovy script. Since Groovy has a great support for parsing well-formed XML-like information it fails if you want to parse unstructured and nasty HTML code.</p>';
    $spot = strpos($html, 'src="', strpos($html, '<img'))+5;
    $spot2 =strpos($html, '"', $spot);
    $imgOfText = substr($html, $spot, $spot2-$spot);

    $spot = strpos($html, '<img');
    $spot2 = strpos($html, '>', $spot)+1;
    $TextWithOutImg = substr($html,0,$spot).substr($html,$spot2);



    echo "Image Source: ".$imgOfText."\n\n";
    echo "Text Without Image:\n".$TextWithOutImg;
    
    

?>


Output:
1
2
3
4
Image Source: story_img.jpg

Text Without Image:
<p>In the last couple of weeks I often had to download a lot of files, submitted to a web-based teaching platform. Downloading all these files by hand is very annoying so I implemented a short Groovy script. Since Groovy has a great support for parsing well-formed XML-like information it fails if you want to parse unstructured and nasty HTML code.</p>


Create a new paste based on this one


Comments: