Jump to content

How do I search and extract text?


oni-kun

Recommended Posts

Imagine I use get_file_contents to place this plaintext into a variable..

Random:
Test data: Hello
Website: www.example.com
------
Time: 3:23PM
Sky: Blue
------
Area: Space
------ END

 

How could I extract..say.. the 'website' line, and what it says after ":" ?

I'd prefer if there were a non-regex way if possible with subchar etc but it doesn't matter for it's a simple use, just text getting the 'something:key' to place into a variable..

 

Pseudocode:

$stuff = get_file_contents('./file.txt');
$result = split($stuff, "website");
echo "Contact: <a href="$result">$result</a>";

 

 

Link to comment
https://forums.phpfreaks.com/topic/169470-how-do-i-search-and-extract-text/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.