BlackHalt writeln (by me or from manual) PHP source Codes ...

Mazliet par preg_match_all

<?php
if(isset($_GET['kaa'])){
    
$a=$_GET['vards'];
    
$b=file_get_contents("http://www.google.lv/pda?q=$a");
    switch(
$_GET['kaa']){
        case 
0:
            
# Visas saites kā saraksts
            
preg_match_all("#<a href=\"(.*?)\">(.*?)</a>#s",$b,$c);
            
$n=count($c[1])-5;
            for(
$i=0;$i<$n;$i++){
                
$tmp=$c[1][$i];
                echo 
$tmp.'<br />';
            }
            break;
        case 
1:
            
# Visas saites kā klikojamas saites
            
preg_match_all("#<a href=\"(.*?)\">(.*?)</a>#s",$b,$c);
            
$n=count($c[0])-5;
            for(
$i=0;$i<$n;$i++){
                
$tmp=$c[0][$i];
                echo 
$tmp.'<br />';
            }
            break;
        case 
2:
            
# Saišu apraksti
            
preg_match_all("#</a>&nbsp;(.*?)<span class=\"url\">#s",$b,$c);
            
$n=count($c[1]);
            for(
$i=0;$i<=$n;$i++){
                
$tmp=$c[1][$i];
                echo 
$tmp.'<br />';
            }
            break;
        default:
            die();
    }
}
?>