read and echo .txt file is giving UNDEFINED OFFSET ERROR in php -
first of all, need have found same type of question in site. followed of solutions, didn't work in case.
i have .txt file need echo out in specific order. here .txt file.
question1|opt1,opt2,opt3;question2|opt1,opt2,opt3;question3|opt1,opt2,opt3;
here code
$open=fopen("mydata.txt","r+"); $blocks = explode(';', file_get_contents('mydata.txt')); foreach($blocks $block) { list($question, $opts) = explode('|', $block); //line 'x' $opt = explode(',', $opts); $eco=$question."</br>".'<input type=radio>'.$opt[0].'<input type=radio>'.$opt[1].'<input type=radio>'.$opt[2]; //line 'y' echo $eco; } fclose($open);
gives me 3 undefined offset notice line x(1 notice) , line y(2 notice). and, gives me 3 radio button blank values.
need help in issue.
i have come solution problem.
using multidimensional array works in case.what have done insert contents arrays , retrieve content that.
it working now.
php error-handling fopen
No comments:
Post a Comment