Welcome visitor
* Login
* Register
It is currently September 15th, 2019, 11:55 pm
All times are UTC [ DST ]
* Search
View unanswered posts - View active topics

FORUMS » Server Side » PHP



Post new topic Reply to topic  [ 2 posts ] 
Author Message
  read first word from a .txt file
PostPosted: May 29th, 2009, 7:58 am 

Posts: 26
hi, idk if im gonna be able to actually use it, but how can i fill an input with the first word of a .txt file? thanks.


Top
 Profile  
 
  Re: read first word from a .txt file
PostPosted: May 29th, 2009, 8:06 am 
User avatar

Posts: 81
<?php
$txt = "test.txt"; // the .txt file should be in the same folder
$handle = fopen($txt, 'r');
$total = fread($handle, filesize($txt)); // $total will be a string with all the .txt file
fclose($handle);
$first= substr($total,0,stripos($total," ")); // then we get from total everything that is before its first space
echo '<input value="' . $first . '"/>';
?>


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

FORUMS » Server Side » PHP


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron