[英]How can I separate the output of the web service?
I get this result from web service in php code:我从 php 代码中的 web 服务得到这个结果:
> stdClass Object (
> [Post_Added_Record_ByMenuIDResult] => stdClass Object
> (
> [HTMLStructure] => ثبت انجام شد
> [IsAuthenticated] => 1
> [MenuID] => 1191
> [Password] =>
> [PersonID] => 27598
> [PersonalityID] => 31413
> [RecordValues] =>
> [RoleID] => 5
> [Sexuality_Title] => m
> [UserName] => mr.piri
> ) )
I want to get the opposite phrase in [HTMLStructure].我想在 [HTMLStructure] 中得到相反的短语。 in this example: ثبت انجام شد
在这个例子中: ثبت انوام شد
if (strstr( $result, 'HTMLStructure' ) ) {
$HTMLStructurePos=strpos( $result, '[HTMLStructure] =>' );
echo $HTMLStructurePos;
$IsAuthenticatedPos=strpos( $result, ' [IsAuthenticated]' );
echo $IsAuthenticatedPos;
$result2 = substr($result, $HTMLStructurePos, $IsAuthenticatedPos);
echo "<pre>";
print_r($result2);
echo "</pre>";
} else {
echo "Not found";
}
but i get但我明白了
Not found
未找到
in the out put.在输出中。
I think this is a structure and I have to get the value with the pointer.But does anyone know how?我认为这是一个结构,我必须用指针获取值。但是有人知道怎么做吗?
You get a nested object back from your Web-Service.您从 Web 服务返回一个嵌套的 object。 Simplified as PHP code:
简化为PHP代码:
$result = (object)['Post_Added_Record_ByMenuIDResult' => (object)[
'HTMLStructure' => "ثبت انجام شد",
'IsAuthenticated' => 1,
//...
]];
The HTML can be accessed simply like this:可以像这样简单地访问 HTML:
$html = $result->Post_Added_Record_ByMenuIDResult->HTMLStructure;
echo $html; // ثبت انجام شد
Just like HTMLStructure, you also get the values like IsAuthenticated.就像 HTMLStructure 一样,您还可以获得 IsAuthenticated 等值。
i solved this problem by this code:我通过这段代码解决了这个问题:
foreach ($result as $obj)
{
// Here you can access to every object value in the way that you want
$result2 = $obj->HTMLStructure;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.