Question:

Whats wrong with this PHP code?

by  |  earlier

0 LIKES UnLike

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

this is on line 5.

<?php

function read_news($filename,$max_words)

{

$file = file($filename ".txt");

for($a = 1; $a < $max_words, $a )

{

echo $file[$a] . " ";

}

}

?>

Much Appreciated,

Aric

 Tags:

   Report

2 ANSWERS


  1. $file = file($filename &quot;.txt&quot;);

    should be $file = file($filename .&quot;txt&quot;);

    for($a = 1; $a &lt; $max_words, $a )

    should be for($a = 1; $a &lt; $max_words; $a )


  2. change , with ; on line 5

Question Stats

Latest activity: earlier.
This question has 2 answers.

BECOME A GUIDE

Share your knowledge and help people by answering questions.