Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/261.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 将字符串和对象的组合转换为对象/数组_Php_Api_Yii2 - Fatal编程技术网

Php 将字符串和对象的组合转换为对象/数组

Php 将字符串和对象的组合转换为对象/数组,php,api,yii2,Php,Api,Yii2,我正在使用Kennot API。为了处理无效数据,我使用try(),catch。现在,当我输入无效数据时,我会在catch函数中打印响应 由于我正在使用Kennot verdor,所以我在下面处理异常 try { } catch (ApiException $e) { exit($e->getMessage(). PHP_EOL); } 它的退出和下面的回应 [400]连接到API时出错 ().stdClass对象( [错

我正在使用Kennot API。为了处理无效数据,我使用try(),catch。现在,当我输入无效数据时,我会在catch函数中打印响应

由于我正在使用Kennot verdor,所以我在下面处理异常

    try
    {

    }
    catch (ApiException $e)
    {
        exit($e->getMessage(). PHP_EOL);
    }
它的退出和下面的回应

[400]连接到API时出错 ().stdClass对象( [错误]=>数组([0]=>stdClass对象([code]=> 400#地址.postalCode?无效[消息]=>无效postalCode)))

现在:我想打印共振的响应消息

我在
字符串
中得到响应,因此如何才能仅获取消息部分

注意:下面是
打印($e->getMessage())
响应:

   [400] Error connecting to the API (https://api-int.kennect.com/v1/candidates) .stdClass Object
    (
    [errors] => Array
     (
        [0] => stdClass Object
            (
                [code] => 400#address.postalCode?invalid
                [message] => invalid postalCode
            )

     )

     )
有没有php函数/其他方法来实现这一点


注意:我不想使用
字符串解析
,因为结果可能会不同。

这看起来不像我从Stripe Payments API中得到的任何错误,
kennot.com
与Stripe有什么关系,它使用
stripe.com
?使用正则表达式匹配
之前的所有内容。stdClass Object
@Barmar这些是Kennot api。*我可以使用php函数吗??除了regex?还能是什么?您只需要根据模式提取字符串的一部分。这不是一种标准格式,它有一个内置的函数来解析它。