XPATH - get single value returned instead of array php

后端 未结 5 1397
不知归路
不知归路 2021-01-15 01:02

I am using Xpath in PHP - I know that my query will return either 0 or 1 results.

If 1 result is returned I do not want it as an array - which is what is returned ri

5条回答
  •  悲&欢浪女
    2021-01-15 01:19

    Using 'evaluate' instead of 'query', you can do things like casting.

    • DOMXPath::evaluate()

    Also, if you're just annoyed with doing stuff a lot of times, just write a function that does it ... that is the whole idea behind functions, right?

提交回复
热议问题