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).
PHP Code:
$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);
Bookmarks