Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.