Jump to content

[SOLVED] Double(+=) arrow in arrays?


Qaaolchoura

Recommended Posts

Hello, sorry if this is idiotic, but I couldn't find the answer either elsewhere.

Is there a way to include a double (or more) arrow in an array, without using subarrays?

 

For example, if I had a set of information about music that I wanted to export as xml (as I did for an experiment).

 

</php
<-- create document, header, etc-->

$dataArray = array("Graceland" => "Paul Simon" => "Rock", "Days of Future Passed" => "Moody Blues" => "Rock");

foreach($dataArray as $nameArr => $artistArr => $genreArr)
{
//create data for name
$name = $dom->createElement('name');
$nameText = $dom->createTextNode($nameArr);
$name->appendChild($nameText);

<--repeat for $artist & $genre-->

// create node for album and add data as child
$album = $dom->createElement('album');
$album->appendChild($name);
$album->appendChild($artist);
$album->appendChild($genre);
}

<--output xml-->
?>

I get an error because of the unexpected double arrow.

 

Ultimately I'd want to draw this from a mySQL database rather than using static arrays, but I'm still wondering if there's a way to do this.  It seems like it'd be useful if I wanted to pass arrays from one php file to another.

 

Thanks,

~Q

Link to comment
https://forums.phpfreaks.com/topic/169256-solved-double-arrow-in-arrays/
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.