$x = '-- \' --';
print $x . "\n"; // -- ' --
$y = '-- \\\' --';
print $y . "\n"; // -- \' --
To specify a literal single quote, escape it with a backslash (\). To specify a literal backslash, double it (\\).https://www.php.net/manual/en/language.types.strin...
const str = "{'id':'147','name':'example's name1','address':'sample street 1'}";
const [_, id, name, address] = str.match(/{'id':'(.*?)','name':'(.*?)','address':'(.*?)'}/);
console.log(id); // 147
console.log(name); // example's name1
console.log(address); // sample street 1
const re = /{'id':'(?<id>.*?)','name':'(?<name>.*?)','address':'(?<address>.*?)'}/;
const result = re.exec("{'id':'147','name':'example's name1','address':'sample street 1'}");
console.log(result.groups);
// Object { id: "147", name: "example's name1", address: "sample street 1" }
axios.get(url[, config])
$property = $json_obj['data'][0];
[
"type" => "property",
"id" => "c0b6c16a-3002-48d3-a832-65311736d4da",
"attributes": [
"inline_address" => "string",
"public_address" => "string"
]
]
foreach($property as $value)
вы перебираете все значения данного массив и на первом же значении получаете "property"['attributes']
. <!DOCTYPE html>
<html lang="ru">
<head>
<meta charset="utf-8" />
<title>JSON Sample</title>
</head>
<body>
<h2>Текст</h2>
<div id="placeholder"></div>
<script>
document.addEventListener(
'DOMContentLoaded',
() => {
fetch('data.json')
.then((response) => response.json())
.then((data) => {
document.getElementById("placeholder").innerHTML =
`<ul>${data.users.map((u) => `<li>${u.firstName} ${u.lastName} -- ${u.joined.month}</li>`).join()}</ul>`
});
},
);
</script>
</body>
</html>