How does javascript obtain the value of a PHP string array? & Lt; table & nbsp; width = "180px;" & nbsp; border = "0" & nbsp; cellspacing = "0" & nbsp; cellpadding = "0" & gt; & nbsp; & nbsp ask javascript how to obtain the value of a PHP string array?
$ I = 0;
While ($ I <10)
{
$ Qgmw [$ I] = $ xml1-> title [$ I]; // title
$ Qgmw [$ I] = mb_substr ($ qgmw [$ I], 0,78, 'utf-8 '); $ qgid [$ I] = $ xml1-> title [$ I]-> attributes ()-> id; // id
$ Qgdj [$ I] = $ xml1-> title [$ I]-> click; // number of clicks
$ I ++;
}
Arsort ($ qgdj, SORT_NUMERIC );
$ T_id = array_keys ($ qgdj );
$ I = 0;
While ($ I <7)
{
$ J = $ I + 1;
Echo"";
Echo" "; Echo $ j.", "; echo"";
Echo""; Echo" ". mb_substr ($ qgmw [$ t_id [$ I], 0, 10, 'utf-8')." "; echo"";
Echo"";
$ I ++;
}
// Echo $ qg [0];
?>
Script
Function ()
{
Var str = "";
Str =" ";
Alert (str );
/* During the test, the values of the following two numeric types can be obtained, but the above $ qgmw [0] is of the string type and cannot be obtained. what should I do?
Str = ;
Str = ;
*/
}
A ();
Script
------ Best solution --------------------
Reference:
This is also the test, and it cannot be obtained. it will not work if it is executed here.
Str =" ";
Reference: Do not enclose strings in quotation marks?
Output $ qgmw [0] to see what it is.
Or use the complete syntax var str =' ';
------ Other solutions --------------------
In this way,
Var str = ;
No errors occur for strings, arrays, or objects.
The string is added with "", the array will [], and the object will {}
------ Other solutions --------------------
Reference:
$ Time = date ("Y, m, d ");
$ Mday = date ("D ");
// Var_dump ($ mday );
If ($ mday = 'mon') $ mday = "Monday ";
Else if ($ mday = 'tue ') $ mday = "Tuesday ";
Else if ($ mday = 'wed') $ mday = "Wednesday ";
Else if ($ mday = '......
Paste the executed HTML code.
We can't run it if you paste it to php.
Or you can use firebug to troubleshoot the error.
------ Other solutions --------------------
Learned
------ Other solutions --------------------
Do not enclose strings in quotation marks?
------ Other solutions --------------------
This is also the test, and it cannot be obtained. it will not work if it is executed here.
Str =" ";
Reference: