http.postを使用してPHPファイルを呼び出し、処理中にjsonオブジェクトを渡しています。 私はPHP内からオブジェクトを取得することができ、以下のダンプを添付しています。私が今必要とするのは、配列から '名前'、 '電子メール'、および 'メッセージ'の文字列を取得することですが、これはPHPにはあまり使われていないため困難です。次のようにPHPファイル内の渡されたパラメータからの配列要素の取得
Connected successfully<pre>string(2467) "Array
(
[name] => Array
(
[$viewValue] => testing one two
[$modelValue] => testing one two
[$validators] => Array
(
)
[$asyncValidators] => Array
(
)
[$parsers] => Array
(
)
[$formatters] => Array
(
[0] =>
)
[$viewChangeListeners] => Array
(
)
[$untouched] =>
[$touched] => 1
[$pristine] =>
[$dirty] => 1
[$valid] => 1
[$invalid] =>
[$error] => Array
(
)
[$name] => fullName
[$options] =>
)
[email] => Array
(
[$viewValue] => [email protected]
[$modelValue] => [email protected]
[$validators] => Array
(
)
[$asyncValidators] => Array
(
)
[$parsers] => Array
(
)
[$formatters] => Array
(
[0] =>
)
[$viewChangeListeners] => Array
(
)
[$untouched] =>
[$touched] => 1
[$pristine] =>
[$dirty] => 1
[$valid] => 1
[$invalid] =>
[$error] => Array
(
)
[$name] => email
[$options] =>
)
[message] => Array
(
[$viewValue] => testing testing
[$modelValue] => testing testing
[$validators] => Array
(
)
[$asyncValidators] => Array
(
)
[$parsers] => Array
(
)
[$formatters] => Array
(
[0] =>
)
[$viewChangeListeners] => Array
(
)
[$untouched] =>
[$touched] => 1
[$pristine] =>
[$dirty] => 1
[$valid] => 1
[$invalid] =>
[$error] => Array
(
)
[$name] => message
[$options] =>
)
)
"
<br /><br />Array
(
[name] => Array
(
[$viewValue] => testing one two
[$modelValue] => testing one two
[$validators] => Array
(
)
[$asyncValidators] => Array
(
)
[$parsers] => Array
(
)
[$formatters] => Array
(
[0] =>
)
[$viewChangeListeners] => Array
(
)
[$untouched] =>
[$touched] => 1
[$pristine] =>
[$dirty] => 1
[$valid] => 1
[$invalid] =>
[$error] => Array
(
)
[$name] => fullName
[$options] =>
)
[email] => Array
(
[$viewValue] => [email protected]
[$modelValue] => [email protected]
[$validators] => Array
(
)
[$asyncValidators] => Array
(
)
[$parsers] => Array
(
)
[$formatters] => Array
(
[0] =>
)
[$viewChangeListeners] => Array
(
)
[$untouched] =>
[$touched] => 1
[$pristine] =>
[$dirty] => 1
[$valid] => 1
[$invalid] =>
[$error] => Array
(
)
[$name] => email
[$options] =>
)
[message] => Array
(
[$viewValue] => testing testing
[$modelValue] => testing testing
[$validators] => Array
(
)
[$asyncValidators] => Array
(
)
[$parsers] => Array
(
)
[$formatters] => Array
(
[0] =>
)
[$viewChangeListeners] => Array
(
)
[$untouched] =>
[$touched] => 1
[$pristine] =>
[$dirty] => 1
[$valid] => 1
[$invalid] =>
[$error] => Array
(
)
[$name] => message
[$options] =>
)
)
</pre>
最初の場所でオブジェクトを取得するPHPコードは次のとおりです。
$data = json_decode(file_get_contents('php://input'), TRUE);
$text = print_r($data,true);
echo "<pre>";
var_dump($text);
echo "<br /><br />";
print_r($text);
echo "</pre>";
は、どのように私は「名前」、「メール」と「メッセージ」の文字列をしてくださいアクセスすることができますか?
ところで配列内から$を削除します。
'$データ[「名前」]'、 '$データ:私はあなたがあなたが読んでいる比較的奇妙なJSONを生成し、いくつかのフレームワークを使用していると仮定しかし、ポイントに、あなたは経由でそれらを得ることができます。 'message'] '、' $ data ['email'] ' –