Jump to content


Help with an Array problem?

  • Please log in to reply
1 reply to this topic

#1 Zharvek

  • New Members
  • Pip
  • Newbie
  • 4 posts

Posted 24 March 2006 - 04:11 PM

Hello all, I have (think it is) an array problem. I am trying to create an component for a CMS system, but thats not what matters... I have collected some information, and code examples, and found some scripts to read an bookmark XBEL xml file, and output it nicely, using no XSL stylesheet, just PHP.

My problem is that I cannot find out how to modify this script to pull more data available from the file.

Currently it will pull, the title, url, and folder the link resides in, and prints it to the browser nicely. I need it to also grab and print the description.

Here is what I have now:


global $database;
$query = "SELECT * FROM jos_ablinks";
$database->setQuery( $query );
$rows = $database->loadObjectList();
$row = $rows[0];

$p = xml_parser_create();
xml_parse_into_struct($p, $simple, $vals, $index);


foreach ($index['FOLDER'] as $k=>$v)

foreach ($index['TITLE'] as $k=>$v)

foreach ($index['BOOKMARK'] as $k=>$v)
if (is_array($vals[$v]['attributes']))


foreach ($bm as $k=>$v)
if ($v=='DDDODDD') 
if (!$l)
} else {
if (substr($v,0,4)=='http')
} else {
if (strlen(trim($v))>0)
if ($l)
if ($v==$row->ignored){}else{
echo '<tr><td><h4>'.htmlspecialchars($v).'</h4></td><tr>';
} else {
echo '<tr><td><a href="'.$lastlink.'">'.htmlspecialchars($v).'</a></td></tr>';


Sorry if that was long, I have tried adding an

foreach ($index['DESC'] as $k=>$v)

Under the one with $index['TITLE'] and after playing around with some code, I got it to print the very last DESC in the XML file, but not a DESC for each item in the xml file. I hope I am being clear with it, I just want to be able to put the DESC in here

<tr><td><a href="'.$lastlink.'">'.htmlspecialchars($v).'</a></td></tr>

to look something like

<tr><td><a href="'.$lastlink.'">'.htmlspecialchars($v).'</a><br />'.$desc.'</td></tr>

Thanks in advance if anyone can help. :-)

#2 keeB

  • Staff Alumni
  • Advanced Member
  • 1,078 posts
  • LocationCalifornia

Posted 24 March 2006 - 04:59 PM

Seems like the data is getting parsed into the variable $index ..

So my plan of action would be to figure out everything that $index contains. Seems logical, no?

print "<pre>";
print "</pre>";

Always very useful.. let me know if you have any further questions.

Also.. Your tabbing is terrible and makes me not want to read your code, at all.

Come visit my site to see my latest projects

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users