btc4cash
btc4cash

Reputation: 325

JSON/PHP issue, cannot echo the value but it's present

I have a small issue. I have a json file which I fetch data from.

When I print_r() the data, I see the field I want. But trying to call them, only 2 on 3 works, one seems to not be fetch-able.

Here the code, if someone have an idea about what's wrong:

Original JSON :

[
{
"ņame": "Xcoin",
"rate": "100.0000",
"status": "online"
}
]

The JSON with print_r()

Array
(
[ņame] => XCoin
[rate] => 100.0000
[status] => online
)

When I fetch individually each fields:

echo $coin['name']."<br>";
echo $coin['rate']."<br>";
echo $coin['status']."<br>";

The result of the previous code:

100.0000
online

Like if the name was not there! How's possible? I have others array and name fetch correctly, using same format.

Upvotes: 0

Views: 34

Answers (2)

Alex Howansky
Alex Howansky

Reputation: 53563

Look at your array keys: ņ !== n so you're referencing an array index that doesn't exist.

I.e., that is not an n in the JSON you're getting, it's one of these characters.

(TIL this thing is called a cedilla.)

Upvotes: 1

Fifciuu
Fifciuu

Reputation: 864

Look it's other character ņame != name

Upvotes: 1

Related Questions