Connecting Tech Pros Worldwide Help | Site Map

Parsing html to php array

 
LinkBack Thread Tools Search this Thread
  #1  
Old July 4th, 2008, 01:25 PM
=?ISO-8859-1?Q?Feij=F3?=
Guest
 
Posts: n/a
Default Parsing html to php array

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, 01:35 PM
=?UTF-8?B?SXbDoW4gU8OhbmNoZXogT3J0ZWdh?=
Guest
 
Posts: n/a
Default 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, 07:55 PM
NC
Guest
 
Posts: n/a
Default 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, 02:25 PM
=?ISO-8859-1?Q?Feij=F3?=
Guest
 
Posts: n/a
Default 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
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,989 network members.