-3

What's wrong in this piece of code? I try to use strstr in an array but I get an error message:

<?php

$url = 'http://' . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
$array = array("modellini", "modelle");
for (i=0;$i<count($array;$i++)) 
{
    $key = strstr($url,$array[$i]);
    $keycap = ucwords($key);
    $bodytag = str_replace("-", " ", $keycap);

    if (false !== $key)
    {
?>

Prova<?php echo $bodytag ?>

<?php
    } else {
        echo 'No cars.';
    }
}
?>

Parse error: syntax error, unexpected '=', expecting ';'

... on this line:

for (i=0;$i<count($array;$i++))
hakre
  • 193,403
  • 52
  • 435
  • 836
  • Seems to be an typo as Danil says below. Next time add the error message to your question or an explanation of what is/went wrong. – Sven van Zoelen Feb 19 '13 at 08:52
  • Please try to make an effort and explain yourself what exactly you think it's wrong. If you force others to guess all the details you'll get less answers and less quality ones. I've completed the question for you. – Álvaro González Feb 19 '13 at 08:52
  • And why break out of PHP at the `Prova – Sven van Zoelen Feb 19 '13 at 08:54
  • might be helpful as well: [How to get useful error messages in PHP?](http://stackoverflow.com/a/14504459/367456) – hakre Feb 19 '13 at 08:58

2 Answers2

3
for (i=0;$i<count($array;$i++)){

reoplace by

for ($i = 0; $i < count($array); $i++) {
Danil Speransky
  • 29,891
  • 5
  • 68
  • 79
0

Oops..

The for (i=0;$i<count($array;$i++)){

should be:

for ($i = 0; $i < count($array); $i++) {
Engineer
  • 5,911
  • 4
  • 31
  • 58