Tutorial :first thing i do in my php function is define an array why is undefined later in the function?


I have a long function with many if statements and such. The first thing i do in my function is this: $text = file($read_text_file);

The $text array contain all text in the site therefor I need this array to be available in my entire function and I though I would accomplice this by defining the variable first thing in the function, but now i discovered that later in a if statement, its blank. Why is this?


Put var_dump($text); on the line immediately after $text = file($read_text_file);. If the array is populated, then you will get the values of the array. If not, then my guess is that there is a problem with the file itself.


As William said in the comments above we really need to see some context of this problem in order to answer this question. There could be any number of issues happening. Are you sure that the file is being read correctly as well?

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Next Post »