The function 'json_decode' returns an object.
In that object you have an array of txs.
Each of those txs is, again, of type object.
You don't need to replace anything on the '$json3' string.
$json_url3 = "https://blockchain.info/da/unconfirmed-transactions?format=json";
$json3 = file_get_contents($json_url3);
$data3 = json_decode($json3);
$tx_count = count($data3->txs);
$latesttx = $data3->txs[$tx_count-1]->hash;