0

I have to Simple code retrieve data from json.i got problem with json properties that contains like department$_identifier. 'department$_identifier' properties contains the value.but php count it as a variable.how to escape this.

Here is my code :

foreach ($data as $key => $Attendance) {
        if ($Attendance->department$_identifier == 'Administration') {
           echo $Attendance->department$_identifier;
           echo $Attendance->attendanceDate;
           echo $Attendance->status;
           echo $Attendance->_entityName;
        }
      }

How to solve this

2 Answers 2

1

use {} like as

echo $Attendance->{'department$_identifier'};

http://php.net/manual/en/function.json-decode.php

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

2 Comments

Thanks a lot,Its Work..Save my time.
@RK-Rohan Feel free to accept it as an answer to your question then, please.
0

Try this

foreach ($data as $key => $Attendance) {
    if ($Attendance["department$_identifier"] == 'Administration') {
        echo $Attendance["department$_identifier"];
        echo $Attendance["attendanceDate"];
        echo $Attendance["status"];
        echo $Attendance["_entityName"];
    }
}

Comments

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.