0

I get the response below from a script, and I need to extract board, model, serial number, current and upgrade.

Net\Response Object
(
    [unrecognizedWords:protected] => Array
        (
        )

    [_type:Net\Response:private] => !re
    [attributes:protected] => Array
        (
            [board] => true
            [model] => CRD
            [serialnumber] => XXXXXXXX
            [current] => 5.11
            [upgrade] => 5.11
        )

    [_tag:Net\Message:private] => 
)

I've multiple combinations such as this:

echo unrecognizedWords:protected->attributes:protected->board;

However I can not get the values our of the array.

Can someone help me?

4
  • Is that what you literally get from the script? If so, it's not a proper array, it looks more like the output from var_dump(). Commented Jul 25, 2016 at 22:37
  • @AlanHorrocks Its a print_r. Commented Jul 25, 2016 at 22:40
  • Thats weird - which kind of Response object it is? Is it part of some kind of public library or is it just your own object? Commented Jul 25, 2016 at 23:12
  • Its a response from Pear. Commented Jul 25, 2016 at 23:21

1 Answer 1

1

You cann't get any protected or private properties of object (only public). Use public methods (getters) of this object (sure, that it's provided).

Read: PHP: Visibility

Sign up to request clarification or add additional context in comments.

3 Comments

Its just the response. I can't just extract the values I need?
You would have to parse the output into a proper array or object before you could make use of it. Do you have control over what the script returns? If so, you could make it return a JSON encoded string, which can be easily made into an object.
@Borsn, what library do you use to get this response?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.