Jump to content

User:Constanstin/Codes

From Wikipedia, the free encyclopedia

PHP Code

[edit]
<?php
// Wiki Markup Link Parser
$output = "";
$source = $_REQUEST['source'];
if (!empty($source)) {
        $output = "";
        if (preg_match_all("/\*['\s]{1,2}?\[\[(.+?)\]\]/", $source, $matches,PREG_PATTERN_ORDER)) {
                for ($i=0; $i<count($matches[1]); $i++) {
                        $title = $matches[1][$i];
                        //take only proper name if delimited by | (pipe)
                        if (strpos($title,"|")>0) $title = substr(strstr($title,"|"),1);
                        //take out anything in parenthesis
                        if (strpos($title,"(")>0) $title = substr($title,0,strpos($title,"("));
                        $output .= "$title\n";
                }
        } else {
                $output = "not found";
        }
}
?>
[edit]
<a href="html_images.asp">HTML Images</a>