Connecting Tech Pros Worldwide Help | Site Map

Parsing html to php array

  #1  
Old July 4th, 2008, 02:25 PM
=?ISO-8859-1?Q?Feij=F3?=
Guest
 
Posts: n/a
I've been trying to find a code or a way to create that

a parse that return this to me:

$html['body']['p'] = 'loren ipsum';
$html['body']['p'] = 'loren ipsum 2';
$html['body']['p']['a'] = 'path/to/a/file';
$html['body']['table']['tr'][0]['th'] = 'header 1';
$html['body']['table']['tr'][0]['th'] = 'header 2';
$html['body']['table']['tr'][0]['th'] = 'header 3';
$html['body']['table']['tr'][1]['td'] = 'column 1';
$html['body']['table']['tr'][2]['td'] = 'column 2';
$html['body']['table']['tr'][3]['td'] = 'column 3';
etc.


thanks for any answer
Feijó
  #2  
Old July 4th, 2008, 02:35 PM
=?UTF-8?B?SXbDoW4gU8OhbmNoZXogT3J0ZWdh?=
Guest
 
Posts: n/a

re: Parsing html to php array


If your input is properly generated XHTML, try out simplexml. If not, pipe
the HTML through tidy to get celan XHTML, then pipe it to simplexml.

--
----------------------------------
Iván Sánchez Ortega -ivan-algarroba-sanchezortega-punto-es-

Now listening to: Fatboy Slim - The Best of Classic Chillout: Sunrise
(2002) - [4] Praise You (full version) (5:21) (96.285698%)
  #3  
Old July 4th, 2008, 08:55 PM
NC
Guest
 
Posts: n/a

re: Parsing html to php array


On Jul 4, 6:18 am, Feijó <afe...@gmail.comwrote:
Quote:
>
I've been trying to find a code or a way to create that
a parse that return this to me:
>
$html['body']['p'] = 'loren ipsum';
$html['body']['p'] = 'loren ipsum 2';
Um, the first line would create an element in the array, the second
line would overwrite that element with a new value. So your approach
to parsing seems to be flawed...

Cheers,
NC
  #4  
Old July 7th, 2008, 03:25 PM
=?ISO-8859-1?Q?Feij=F3?=
Guest
 
Posts: n/a

re: Parsing html to php array


It was just a example I wrote to better explain, I just forget to add
[] at the end on both lines :)


On Jul 4, 4:53*pm, NC <n...@iname.comwrote:
Quote:
On Jul 4, 6:18 am, Feijó <afe...@gmail.comwrote:
>
Quote:
I've been trying to find a code or a way to create that
a parse that return this to me:
>
Quote:
$html['body']['p'] = 'loren ipsum';
$html['body']['p'] = 'loren ipsum 2';
>
Um, the first line would create an element in the array, the second
line would overwrite that element with a new value. *So your approach
to parsing seems to be flawed...
>
Cheers,
NC
Closed Thread


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to insert values into mysql, after parsing a submiting textbox? blitzztriger answers 2 July 20th, 2007 11:12 PM
Yahoo! UI + PHP Array Sascha Deus answers 3 April 13th, 2007 03:05 PM
new to PHP Stewart Robert Hinsley answers 5 July 17th, 2005 06:02 AM