从API响应问题中提取数据

I have been trying to extract data from an xml response which looks like:

Array
(
    [apiversion] => 2
    [data] => Array
        (
            [0] => Array
                (
                    [basedir] => public_html/camnevbritishsweets.co.uk
                    [dir] => /home/paydayci/public_html/camnevbritishsweets.co.uk
                    [domain] => camnevbritishsweets.co.uk
                    [domainkey] => camnevbritishsweets_paydaycic2013.co.uk
                    [fullsubdomain] => camnevbritishsweets.paydaycic2013.co.uk
                    [reldir] => home:public_html/camnevbritishsweets.co.uk
                    [rootdomain] => paydaycic2013.co.uk
                    [status] => not redirected
                    [subdomain] => camnevbritishsweets
                )

            [1] => Array
                (
                    [basedir] => public_html/camnevdomains.info
                    [dir] => /home/paydayci/public_html/camnevdomains.info
                    [domain] => camnevdomains.info
                    [domainkey] => camnevdomains_paydaycic2013.co.uk
                    [fullsubdomain] => camnevdomains.paydaycic2013.co.uk
                    [reldir] => home:public_html/camnevdomains.info
                    [rootdomain] => paydaycic2013.co.uk
                    [status] => not redirected
                    [subdomain] => camnevdomains
                )

            [2] => Array
                (
                    [basedir] => public_html/cossacksoft.com
                    [dir] => /home/paydayci/public_html/cossacksoft.com
                    [domain] => cossacksoft.com
                    [domainkey] => cossacksoft.com_paydaycic2013.co.uk
                    [fullsubdomain] => cossacksoft.com.paydaycic2013.co.uk
                    [reldir] => home:public_html/cossacksoft.com
                    [rootdomain] => paydaycic2013.co.uk
                    [status] => not redirected
                    [subdomain] => cossacksoft.com
                )

            [3] => Array
                (
                    [basedir] => public_html/dog-care-advisor.com
                    [dir] => /home/paydayci/public_html/dog-care-advisor.com
                    [domain] => dog-care-advisor.com
                    [domainkey] => dog-care-advisor.com_paydaycic2013.co.uk
                    [fullsubdomain] => dog-care-advisor.com.paydaycic2013.co.uk
                    [reldir] => home:public_html/dog-care-advisor.com
                    [rootdomain] => paydaycic2013.co.uk
                    [status] => not redirected
                    [subdomain] => dog-care-advisor.com
                )

            [4] => Array
                (
                    [basedir] => public_html/dolphinroboticpoolcleaner.info
                    [dir] => /home/paydayci/public_html/dolphinroboticpoolcleaner.info
                    [domain] => dolphinroboticpoolcleaner.info
                    [domainkey] => dolphinroboticpoolcleaner.info_paydaycic2013.co.uk
                    [fullsubdomain] => dolphinroboticpoolcleaner.info.paydaycic2013.co.uk
                    [reldir] => home:public_html/dolphinroboticpoolcleaner.info
                    [rootdomain] => paydaycic2013.co.uk
                    [status] => not redirected
                    [subdomain] => dolphinroboticpoolcleaner.info
                )

            [5] => Array
                (
                    [basedir] => public_html/ff666fffff.com
                    [dir] => /home/paydayci/public_html/ff666fffff.com
                    [domain] => ff666fffff.com
                    [domainkey] => ff666fffff.com_paydaycic2013.co.uk
                    [fullsubdomain] => ff666fffff.com.paydaycic2013.co.uk
                    [reldir] => home:public_html/ff666fffff.com
                    [rootdomain] => paydaycic2013.co.uk
                    [status] => not redirected
                    [subdomain] => ff666fffff.com
                )

            [6] => Array
                (
                    [basedir] => public_html/ff8v.com
                    [dir] => /home/paydayci/public_html/ff8v.com
                    [domain] => ff8v.com
                    [domainkey] => ff8v.com_paydaycic2013.co.uk
                    [fullsubdomain] => ff8v.com.paydaycic2013.co.uk
                    [reldir] => home:public_html/ff8v.com
                    [rootdomain] => paydaycic2013.co.uk
                    [status] => not redirected
                    [subdomain] => ff8v.com
                )

            [7] => Array
                (
                    [basedir] => public_html/ff8v77.com
                    [dir] => /home/paydayci/public_html/ff8v77.com
                    [domain] => ff8v77.com
                    [domainkey] => ff8v77.com_paydaycic2013.co.uk
                    [fullsubdomain] => ff8v77.com.paydaycic2013.co.uk
                    [reldir] => home:public_html/ff8v77.com
                    [rootdomain] => paydaycic2013.co.uk
                    [status] => not redirected
                    [subdomain] => ff8v77.com
                )

        )

    [event] => Array
        (
            [result] => 1
        )

    [func] => listaddondomains
    [module] => Park
    [postevent] => Array
        (
            [result] => 1
        )

    [preevent] => Array
        (
            [result] => 1
        )

)

This is only part of the response as it was too big to paste, what i have so far is:

  // get addon domain list
  $addons = $xmlapi->listaddondomains($cpanelU);

  // debug which prints the response
  print "<pre>"; print_r($addons); print "</pre>";

  // keep these domains
  $keep = array("ff8v77.com","dolphinroboticpoolcleaner.info");

  // loop over the domains
  foreach ($addons['data'] as $value) 
  {
        //echo $value["domain"] . "<br />"; 
        echo str_replace('​', "", $keep);
        if (in_array(trim($value["domain"]), $keep)) 
        {
           echo 'IN Array > ' . $value["domain"] . "<br />";
        } else {
           echo 'NOT IN Array > ' . $value["domain"] . "<br />";
        }   
  }

$addons is what holds the response, as it is just now, it's printing the first domain only X times, also when it's printed to page the domains look like: camnevdomains.​info this symbol "​" is new to me i have never seen this before, so my $keep array is failing becuase this is added to the domain for some reason.

any tips would be appreciated on the best way to handle this reponse.

You could probably try along these lines - using a character conversion function such as mb_convert_encoding to convert the string to utf-8

$keep = array(
    "ff8v77.com",
    "dolphinroboticpoolcleaner.info"
);
$badchars='​';

$data = $addons['data'];

foreach( $data as $index => $arr ){
    if( is_array( $arr ) && array_key_exists( 'domain', $arr ) ){

        $domain = $arr['domain'];
        $domain = stripslashes( trim( mb_convert_encoding( $domain, 'HTML-ENTITIES', 'UTF-8' ) ) );

        if( in_array( $domain, $keep ) ){
            $keep[]=$domain;
        }
    }
}

Also worth trying is to ensure that your html has the correct meta-tags

<meta charset='utf-8' />

or, the older notation

<meta http-equiv='Content-Type' content='text/html; charset=UTF-8' />