How to classify the web page?

Here i attached my codings i going to classify the web page like sports,education,etc i used explode function for split abbreviation in url and used switch case for string comparison but i ll expect category value like 0,1,2,etc… which it belogs to?At the same time i ll expect the category value in notepad also but the solution is didnt work,help me sir.

<?php


string y[6]={‘arts’,‘sports’,‘finance’…}
for(i=0;i<=6;i++)
{
b=strcmp($x,$y[i])
if(b==0)
{
c=y[i];
}
}

switch ($c)
{
case “arts”:
return att1=1;
break;
case “sports”:
return att1=2;
break;
case “finance”:
return att1=3;
break;
.
.
.
}

$myFile = “dataset_doc.txt”;
$fh = fopen($myFile, ‘a’);
$format=“1:”;
fwrite($fh,$format);
fwrite($fh, $att0);

?>

Welcome to the SP forums.

I’m sorry, but I don’t understand what you’re asking, and I also don’t understand what that code is supposed to do?

Woah.

That’s a mix of PHP and something else C-based right there. I’d suggest sticking to learning one programming language at a time.

First of all, name your variables well! Things get very complicated if you don’t, and longer naming isn’t taxing on the compiler.

Secondly, to learn PHP isn’t just learning the syntax and applying C-logic. There is a whole library of functions and structures you can use in PHP which aren’t available in C (and the reverse is also true).


$Categories = array('Arts', 'Sports', 'Finance', 'etc');
$Search = 'Sports';

$CategoryKey = array_search($Search, $Categories);

if($CategoryKey === false){
    $CategoryKey = "Not Found";
}else{
    $CategoryKey++;
}

file_put_contents('dataset_doc.txt', '1:' . $CategoryKey);