alin19 Posted January 17, 2008 Share Posted January 17, 2008 i have a book from where i read and learn php, i found a comand that i could took a var, for example: $x='john is gowing to the bank' and separate it like this: $x1='john'; $x2='is'; $x3='gowing'; . . . but i can't find it now, can you help me? Link to comment https://forums.phpfreaks.com/topic/86450-solved-splithing-a-line/ Share on other sites More sharing options...
pdkv2 Posted January 17, 2008 Share Posted January 17, 2008 Hi use following code snippet. $x='john is gowing to the bank'; $arr=explode(" ",$x); print_r($arr); you will get the array $arr containing the parts of the string. Rgds Sharad Link to comment https://forums.phpfreaks.com/topic/86450-solved-splithing-a-line/#findComment-441767 Share on other sites More sharing options...
alin19 Posted January 17, 2008 Author Share Posted January 17, 2008 <?php $x= file ('C:\Documents and Settings\Administrator\Desktop\php\john.txt'); $n = count ($x); $rand= rand (0,($n-1)); echo trim ($x[$rand]); $arr=explode(" ",$rand); print_r($arr); ?> i want to take a specific line from my file, and print that line how you show me, Link to comment https://forums.phpfreaks.com/topic/86450-solved-splithing-a-line/#findComment-441781 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.