可能重复:
我有一个从php文件返回的json对象,如下所示:
{"food":[
{
"name" :"Belgian Waffles",
"price" :"$5.95",
"description":"two of our famous Belgian Waffles with plenty of real maple syrup",
"calories"
我有一张表格。如果出现错误,则会显示错误消息。目前它只显示一条错误消息,即使我使用PHP和json对数组进行编码,将错误消息推入数组。
我基本上想做的是:
$errors = []; // Array creation
if (strlen($username) < 5) {
// Add this error to our list
$errors[] = 'Username not valid.';
}
if ($password != $passwordRetype) {
// Add this error to our list
问题
我有一个页面,它是通过完全通过生成的。我通过从子域(ajx.example.com) )上的PHP脚本请求数据来获取内容,然后以JSON格式返回数据。
如果用户登录(这是JSON,"isEditable":true中的键之一),这个特定页面的要求之一是“可编辑的”。如果我直接访问请求页面(在子域上),并且用户登录(在主域),那么isEditable就是 and true。但是,如果我通过Ajax请求请求它,那么它总是false。
这些子域是通过VirtualHost on MAMP完成的,它们都指向同一个目录。
www.example.com在htdocs/exampl
我看到了这么多的答案,但我就是不能让它起作用。
我想检查数组中是否有(部分)值。
//Get DNS records
$result = dns_get_record("php.net", DNS_ALL);
print_r($result);
//If the value php-smtp3.php.net is found, echo it
if (in_array("php-smtp3.php.net", $result )) {
echo "Found!";
}
添加了:json_encoded $result,来自我的网络
我有以下表格:
CREATE TABLE sequence (
id serial PRIMARY KEY
-- ...other sequence data
)
CREATE TABLE sound (
id serial PRIMARY KEY
-- ...other sound data
)
CREATE TABLE layer (
id serial PRIMARY KEY,
index smallint NOT NULL,
sequence integer NOT NULL REFERENCES sequence (id)
)
CREATE TABL