I do the next SOAP call:

$soapclient = new SoapClient(self::getParameterByKey(self::$WDSL));

$response = $soapclient->getAllProductsAndOffers(array("province_id" => $province_id, "city_id" => 
$city_id, "code" => $code, "favoritos" => $favoritos, "tipo" => $tipo));

THE CONNECTIONOF MY SOAP IS GOING FINE. NO PROBLEM.

I get the result:

object(stdClass)#10 (1) { ["getAllProductsAndOffersResult"]=> object(stdClass)#9 (3) { ["data"]=> object(stdClass)#8 (1) { ["ProductsOffers"]=> array(3) { [0]=> object(stdClass)#7 (13) { ["bussiness_id"]=> int(1) ["city_id"]=> int(899) ["codigo"]=> string(10) "davidtest1" ["created_date"]=> string(19) "2014-04-30T00:15:05" ["id"]=> int(7) ["img_url"]=> string(0) "" ["latitud"]=> float(41.385589) ["longitud"]=> float(2.168745) ["nombre"]=> string(0) "" ["porcentaje"]=> float(0) ["province_id"]=> int(33) ["tipo"]=> string(1) "P" ["value"]=> float(123) } [1]=> object(stdClass)#6 (13) { ["bussiness_id"]=> int(1) ["city_id"]=> int(899) ["codigo"]=> string(8) "alava-01" ["created_date"]=> string(19) "2014-04-27T01:57:18" ["id"]=> int(5) ["img_url"]=> string(0) "" ["latitud"]=> float(41.385589) ["longitud"]=> float(2.168745) ["nombre"]=> string(0) "" ["porcentaje"]=> float(50) ["province_id"]=> int(33) ["tipo"]=> string(1) "O" ["value"]=> float(500) } [2]=> object(stdClass)#5 (13) { ["bussiness_id"]=> int(1) ["city_id"]=> int(899) ["codigo"]=> string(6) "da-003" ["created_date"]=> string(19) "2014-04-27T01:05:39" ["id"]=> int(4) ["img_url"]=> string(0) "" ["latitud"]=> float(41.385589) ["longitud"]=> float(2.168745) ["nombre"]=> string(0) "" ["porcentaje"]=> float(0) ["province_id"]=> int(33) ["tipo"]=> string(1) "P" ["value"]=> float(2000) } } } ["err"]=> bool(false) ["message"]=> string(2) "ok" } }

The Result to convert the object to array is:

array(1) { ["getAllProductsAndOffersResult"]=> array(3) { ["data"]=> array(1) { ["ProductsOffers"]=> array(3) { [0]=> array(13) { ["bussiness_id"]=> int(1) ["city_id"]=> int(899) ["codigo"]=> string(10) "davidtest1" ["created_date"]=> string(19) "2014-04-30T00:15:05" ["id"]=> int(7) ["img_url"]=> string(0) "" ["latitud"]=> float(41.385589) ["longitud"]=> float(2.168745) ["nombre"]=> string(0) "" ["porcentaje"]=> float(0) ["province_id"]=> int(33) ["tipo"]=> string(1) "P" ["value"]=> float(123) } [1]=> array(13) { ["bussiness_id"]=> int(1) ["city_id"]=> int(899) ["codigo"]=> string(8) "alava-01" ["created_date"]=> string(19) "2014-04-27T01:57:18" ["id"]=> int(5) ["img_url"]=> string(0) "" ["latitud"]=> float(41.385589) ["longitud"]=> float(2.168745) ["nombre"]=> string(0) "" ["porcentaje"]=> float(50) ["province_id"]=> int(33) ["tipo"]=> string(1) "O" ["value"]=> float(500) } [2]=> array(13) { ["bussiness_id"]=> int(1) ["city_id"]=> int(899) ["codigo"]=> string(6) "da-003" ["created_date"]=> string(19) "2014-04-27T01:05:39" ["id"]=> int(4) ["img_url"]=> string(0) "" ["latitud"]=> float(41.385589) ["longitud"]=> float(2.168745) ["nombre"]=> string(0) "" ["porcentaje"]=> float(0) ["province_id"]=> int(33) ["tipo"]=> string(1) "P" ["value"]=> float(2000) } } } ["err"]=> bool(false) ["message"]=> string(2) "ok" } }

To convert I use the next function I found in internet:

public static function objectToArray($d) {
        if (is_object($d)) {
            // Gets the properties of the given object
            // with get_object_vars function
            $d = get_object_vars($d);
        }

        if (is_array($d)) {
            /*
                * Return array converted to object
            * Using __FUNCTION__ (Magic constant)
            * for recursive call
            */
            return array_map("self::" . __FUNCTION__, $d);
        }
        else {
            // Return array
            return $d;
        }
    }

My question is why do I get all data like float(...), string(...), int(...)?

Can I avoid this and really my array containts only the real data without the format?

I want this kind of information:

["ProductsOffers"]=> array(3) { 
    [0]=> array(13) { 
        ["bussiness_id"]=> 1 
        ["city_id"]=> 899
        ["codigo"]=> "davidtest1" 
        ["created_date"]=> "2014-04-30T00:15:05" 
        ["id"]=> 7 
        ["img_url"]=> "" 
        ["latitud"]=> 41.385589
        ["longitud"]=> 2.168745
        ["nombre"]=> "" 
        ["porcentaje"]=> 0 
        ["province_id"]=> 33
        ["tipo"]=> "P" 
        ["value"]=> 123
    } 
    ...
}

NO THIS what it is returned for the soap call:

["ProductsOffers"]=> array(3) { 
    [0]=> array(13) { 
        ["bussiness_id"]=> int(1) 
        ["city_id"]=> int(899) 
        ["codigo"]=> string(10) "davidtest1" 
        ["created_date"]=> string(19) "2014-04-30T00:15:05" 
        ["id"]=> int(7) 
        ["img_url"]=> string(0) "" 
        ["latitud"]=> float(41.385589) 
        ["longitud"]=> float(2.168745) 
        ["nombre"]=> string(0) "" 
        ["porcentaje"]=> float(0) 
        ["province_id"]=> int(33) 
        ["tipo"]=> string(1) "P" 
        ["value"]=> float(123) 
    } 
    ...
}
有帮助吗?

解决方案

You can use var_dump($returnedArray); function and the output should show you the result with type.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top