Skip to content
Advertisement

How to turn associative array into separate variables? [closed]

Here is an example:

PHP:::

<?php

$tag = id3_get_tag( "path/to/example.mp3" );

print_r($tag);

?>

response

Array

(

    [title] => DN-38416

    [artist] => Re:Legion

    [album] => Reflections

    [year] => 2004

    [genre] => 19

)

I want to set this like

$title => DN-38416

$artist => Re:Legion

$album => Reflections

Advertisement

Answer

If you mean to assign value to new variables, simply do it using the assignment operator = in PHP.

$title = $tag["title"];

$artist = $tag["artist"];

// ... and so on

Read more about assignment operator in PHP.

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement