0

This is my sample associative array:

Array (
    [0] => Array (
        [Name] => ALCOIN
        [BasePlugin] => HTTP
        [Version] => 1
        [Description] => Plugin for ALCO_IN operations
        [ImagePath] => ./resources
        [xip] => http://www.example.org/XIP
        [xsi] => http://www.w3.org/2001/XMLSchema-instance
        [schemaLocation] => http://www.example.org/XIP XIP.xsd
    )
    [1] => Array (
        [xip:Action] => Array (
            [@attributes] => Array (
                [Name] => OfferActivationByOfferID
                [Version] => 1.0
                [ImagePath] => ./resources
            )
        )
    )
)

In that array I need to get the BasePlugin value and the name attribute value.

Ethan
  • 4,295
  • 4
  • 25
  • 44

2 Answers2

3

It seems you might need this:

$basePlugin = $yourArray[0]['BasePlugin'];
$attributes = $yourArray[1]['xip:Action']['@attributes'];
Fjarlaegur
  • 1,395
  • 1
  • 14
  • 33
0

Assuming you are assigned to $yourVar like:

$yourVar = Array (
    [0] => Array (
        [Name] => ALCOIN
        [BasePlugin] => HTTP
        [Version] => 1
        [Description] => Plugin for ALCO_IN operations
        [ImagePath] => ./resources
        [xip] => http://www.example.org/XIP
        [xsi] => http://www.w3.org/2001/XMLSchema-instance
        [schemaLocation] => http://www.example.org/XIP XIP.xsd
    )
    [1] => Array (
        [xip:Action] => Array (
            [@attributes] => Array (
                [Name] => OfferActivationByOfferID
                [Version] => 1.0
                [ImagePath] => ./resources
            )
        )
    )
)

You would use:

echo $yourVar[0]["BasePlugin"];
echo $yourVar[1]["xip:Action"]["@attributes"]["Name"];
echo $yourVar[1]["xip:Action"]["@attributes"]["Version"];
echo $yourVar[1]["xip:Action"]["@attributes"]["ImagePath"];
Bloafer
  • 1,324
  • 7
  • 12