How to access falues in my array

hi

have an array getting from a function and when i’m using print_r, print_r($answer).

the string i get:


Array ( [DomainCheckResult] => Array ( [@attributes] => Array ( [Domain] => mystuff.com [Available] => false ) ) ) 

if i want to print\use the domain(mystuff.com) and Available(false) attributes how can i do it ?

thanks

Let’s format that better to understand it:


$answer = array(
  'DomainCheckResult' => array(
    '@attributes' => array(
      'Domain' => 'mystuff.com',
      'Available' => false
    )
  )
);

This is a multi-dimensional array, meaning arrays inside arrays, so we need to use multiple square brackets:

This will output the string mystuff.com


echo $answer['DomainCheckResult']['@attributes']['Domain'];

And you can use the true/false value like this:


if ($answer['DomainCheckResult']['@attributes']['Available']) {
  echo $answer['DomainCheckResult']['@attributes']['Domain'] . ' is available.';
} else {
  echo $answer['DomainCheckResult']['@attributes']['Domain'] . ' in not available.'];
}