Hello,
I got terrible need :)

I have this:

$profile_data = file_get_contents("http://tyxo.bg/d/148025/daily"); 
$sep1 = explode('<table id="general-table">', $profile_data); 
$set2 = explode("</table>", $sep1[1]); 
echo $set2[0];

which output this:
http://i.imgur.com/2THUUve.png

I need to export only this values without anything else:
http://i.imgur.com/IQG708Q.png

You can test by your self the code i give - he outputs the html which is needed to parse from preg_replace or something else maybe?
I dont know how to proceed, this is not my best part.
I want to get only values in red (only this - without anything else)
And i want to separate by comma everything value.

I want this info for one my js scripts which need this information. I will place info later in jquery diagrams to have cool stats, like this:
http://i.imgur.com/nbl0KF2.png

Thanks for any replies and sorry for my english (isnt good)

Recommended Answers

All 6 Replies

Member Avatar for diafol

What about the first set of numbers: 1,5,22,4 - does it make sense to have these? Are they column titles? If not how do they relate to the date, if at all?

EDIT
OK - just realised it's 'Today'. Will have a look.

I want it, it has important values.

Now i get the dates (everything OK with them) and now i need only numbers in four red columns (after columns with dates)

Thanks for your reply!

Member Avatar for diafol

OK, here's a spaghetti version... I'm tired - that's my excuse!

<?php
header('Content-Type: text/html; charset=utf-8');
$doc = new DOMDocument();
libxml_use_internal_errors(true);
$doc->loadHTMLFile("http://tyxo.bg/d/148025/daily");

$xpath = new DOMXpath($doc);
$elements = $xpath->query("//*/tbody/tr/td");
$output = "<table>";
$x=0;$y=0;
  foreach ($elements as $element) {
    if($x%7==0) $output .= "<tr>";
    $output .= ($y == 5 || $y ==1) ? '' : "\t<td>" . $element->nodeValue . "</td>\n";
    $x++;$y++;
    if($x%7==0){
         $output .= "</tr>";
         $y=0;
    }
  }
$output .= "</table>";
echo $output;
?>

Thanks! Its work. Now i need string with specific values from column.

$date = array('0'=>'06.Окт.2014','1'=>'05.Окт.2014'..............20)
$visits = array('0'=>'22','1'=>'154'..............)
$unique = array('0'=>'23','1'=>'98'..............20)
$impressions = array('0'=>'223','1'=>'3,495'..............20)
$maxoline = array('0'=>'4','1'=>'12'.............20)

Yep, i need this to put in js.
Thanks for your help, but i dont know how to get only this values in specific string. Now one string catch all. I try with $output[1] or 2,3,4 - but give me only one value. Maybe this is html :)
Its little retardless request, but its necessary for me.

Member Avatar for diafol

This seems a strange way to set up your data, but ok. You don't include "today" data in your arrays - is this a mistake?

Member Avatar for diafol

Something like this?
NOT TESTED

header('Content-Type: text/html; charset=utf-8');
$doc = new DOMDocument();
libxml_use_internal_errors(true);
$doc->loadHTMLFile("http://tyxo.bg/d/148025/daily");

$xpath = new DOMXpath($doc);
$elements = $xpath->query("//*/tbody/tr/td");

$data = array();

$arrays = array(0=>'date',2=>'visits',3=>'unique',4=>'impressions',6=>'maxoline');
$x=0;
foreach ($elements as $element) {
    if(isset($arrays[$x]))
    {
        $data[$arrays[$x]][] = $element->nodeValue; 
    }
    $x++;
    if($x%7 == 0) $x=0;
}

extract($data);

//test

print_r($date);

print_r($unique);
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.