Get and split in php text from text-file
Discuss coding issues, and scripts related to PHP and MySQL.
-
JanMolendijk
- Posts:282
- Location:Holland Rotterdam
Get and split in php text from text-file
Dear Admin i`m back again with something new...
How can i show into a php document text from an text-file ?
i have this code into the text file
name: poll_result
My text is:
Factly i would like to see only the score 184 or the 2
but i`m also happy with both results (whole)
Admin
Posts:805
Hello,
You can use
file_get_contents() to get a string with file data.
Then, with
explode() you can split that string by the separator you want, and store the resulted items into an array.
- Here is a code example:
Code: Select all
$file ='path_to/filename'; //path to the text file
$fdata = file_get_contents($file); //get file data
$fdata = explode('||', $fdata); //split text data by '||', results into an array
//show data from 1st and 2nd item
echo $fdata[0];
echo '<br>'. $fdata[1];
Similar Topics
- Speech to text without https
General Forum
First post
Pleasant Coursesweb,
Is their anything posible without https for speech to text fill-in ?
Or must I turn my SSL document on the XAMPP-server ?
Last post
Hello,
I don't know about speech to text fill-in.
Anyway, I want to inform you that this forum will be closed for register or posting.
Any...
- GET_id not working in UnLink (delete file)
PHP - MySQL
First post
I searching for an hour for a solution; unlink seems not to work with GET id
<?php
$id = (int) $_GET ;
echo $_GET ;
$file = fopen( '.$_GET...
Last post
Here is an answer `o god after 2 hours shame on me for this one`
<?php
$file_pointer = $_GET .'.txt';
if (!unlink($file_pointer)) {
echo (...