PHP code example of osoobe / dubizzle

1. Go to this page and download the library: Download osoobe/dubizzle library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

osoobe / dubizzle example snippets



use Dubizzle\Search;

$params = ["country"=>'uae', "city"=>"dubai", "section"=>"motor"];
$uea = new Search($params);
$query = $uea->search();
$query->fetch();

$results = $query->get_results();



var_dump($results);

[
    ['title' => '...',
     'location' => '...',
     'url' => '...',
     'price' => '...',
     'category' => '...'
    ],
    ['title' => '...',
     'location' => '...',
     'url' => '...',
     'price' => '...',
     'category' => '...'
    ],
    ...
]



use Dubizzle\Search;

$params = [
    "keyword"=>'altima',
    "country"=>'uae',
    "city"=>'dubai',
    "section"=>'motors',
    "category"=>'cars',
    "make"=>'nissan',
    "min_year"=>2007,
    "num_results"=>'all'];

$uae = new Search($params);

$query = $uae->search();
$query->fetch();
$results = $query->get_results();

$result_count = count($results);
$total_price = 0;
foreach($results as $result){
    $total_price += $result["price"];
}

echo "Num. Results:   ".$result_count;
echo "<br/>";
echo "<br/>";
echo "Average price:  ".(intval($total_price / $result_count)); # Prints 39239.94


use Dubizzle\Category;

$category = new Category();
$makes = $category->get_makes(Category::$uae["categories"]["options"]['cars']);


use Dubizzle\Category;

$category = new Category();
$models = $category->get_models(Category::$uae["makes"]["options"]['audi']);