Search the Community
Showing results for tags 'markov'.
-
Hi I was given a assignment in college to write a "markov text generator". My code was working the other day when the errors on the server were shut off, they have however put these errors back on and I am receiving the following error: Notice: Undefined offset: 104 in /users/2017// on line 32 d Notice: Undefined offset: 134 in /users/2017/ on line 32 Notice: Undefined offset: 206 in /users/2017/on line 32 e Notice: Undefined offset: 304 in /users/2017//markov.php on line 32 e Notice: Undefined offset: 400 in /users/2017//markov.php on line 32 h My code is as follows: $textarea = trim ( $_GET['textarea'] ); $textsize = $_GET['textsize']; $textarea = strtolower ( $textarea ); $string = rand(0, strlen($textarea)-1); $string = $textarea[$string]; $textarray = str_split( $textarea ); $count = 1; $newstr = ""; $position = 0; while ( $count < 200 ) { foreach ( $textarray as $char ) { if ( $char == $string ) { $string = $textarray[$position++]; $newstr .= $string; } $position++; } echo $string = $newstr[rand(0, strlen($newstr)-1)]; $count++; } Line 32 is : $string = $textarray[$position++]; Any help would be greatly appreciated