I am trying to pass values for Array through PHP but i cant get to make work! Some one please help here is the code i tried <?php $masterkeylist11 = file_get_contents('http://domain.com.com/full/forbidden/finalkeys.txt'); $myvar = array($masterkeylist11); echo $myvar[3]; ?> PHP: The in file contents of finalkeys.txt googlecom,yahoocom,bingcom,rediffcom,ebaycom,googleus,googleca, PHP: Some one please tell me whats the error here
text.txt contents: text1,text2,text3,text4 Code (markup): <?php $masterkeylist11 = file_get_contents('text.txt'); // all text inside the file seperated by comma $value = explode(',', $masterkeylist11); // explode the comma and put each text in the array($values) as an element echo $values[0] . "<br />"; // First text echo $values[1] . "<br />"; // Second text echo $values[2] . "<br />"; // Third text echo $values[3] . "<br />"; // Fourth text ?> Code (markup): hope it helps, Thanks
A small modification to the code above: finalkeys.txt googlecom,yahoocom,bingcom,rediffcom,ebaycom,googleus,googleca, Code (markup): <?php $masterkeylist11 = file_get_contents('/full/forbidden/finalkeys.txt'); $eachValue = explode(',', $masterkeylist11); $length = count($eachValue); for ($i=0; $i<$length; $i++){ echo $eachValue[$i].'<br/>'; } ?> PHP: You can try that. Also, the path to your text file, must be relative to the PHP file in which it is being called. I may be wrong but I don't think you can access it through the domain name like you had in your example.
i was going to do a loop too ^^, but i noticed that he is trying to echo specific value not all otherwise thanks for the modification Cheers