views:

64

answers:

1

Using php coding, I'm attempting to make a script which will grab content from another URL and give each word/number a php variable. I'm unsure whether this is possible, hence the reason why I've come onto stackoverflow and hoping for assistance from other members.

This is what I've currently got:

<?php

$searchdata = file_get_contents('http://www.example.com/dynamic.html');
echo $searchdata;

?>

The code grabs the data from the page titled "dynamic.html" and displays it. The content within dynamic.html is simply a line of text, each word is separated by a single space. The contents within the page looks something similar to:

92 AULLAH1 325 6523 37 1 12 5 #endofscript

I've said it looks similar to, as this is a dynamic page and varies all the time. The thing I'd like to do is give each number/word a php variable. E.G. 92, AULLAH1, 325, 6523, 37, 1, 12, 5 each should have a separate variable ($number, $text etc...). Notice I don't require a variable for #endofscript.

How would I go about doing this? The document is a dynamic page, so the numbers may be different as well as "AULLAH1".

Kind regards, and I appreciate every single response. :)

+2  A: 

The number of data is fixed? Can you name them all?

list($number, $text, $othernumber, $phone, $age, 
     $smth, $andd, $last) = explode(" ", $searchdata);
galambalazs
Hey galambalazs, thank you for your response, it is extremely appreciated! :) Yes, the number of data within the file is always the same unless the content isn't found, it will simply display one word, however this isn't a problem. The code you provided works more than just perfect and I really do appreciate it and am thankful for the reply. :)
AUllah1
you're welcome :)
galambalazs