有人可以帮我转换为PHP吗?
var encoded = '';
var resnumber = 0;
for (v = 1; v <= evnumber; v++) {
var indcode = v + 'code';
var valcode = document.getElementById(indcode).value;
valcode = valcode.trim();
var indname = v + 'name';
var valname = document.getElementById(indname).value;
valname = valname.trim();
var indleague = v + 'league';
var valleague = document.getElementById(indleague).value;
valleague = valleague.trim();
var inddate = v + 'date';
var valdate = document.getElementById(inddate).value;
valdate = valdate.trim();
var indtime = v + 'time';
var valtime = document.getElementById(indtime).value;
valtime = valtime.trim();
var indnumb = v + 'numb';
var valnumb = document.getElementById(indnumb).value;
valnumb = valnumb.trim();
valnumb = parseInt(valnumb);
encoded = encoded + valcode + '<e>' + valname + '<e>' + valleague + '<e>' + valdate + '<e>' + valtime + '<e>' + valnumb + '<e>';
for (w = 0; w < valnumb; w++) {
var indtype = v + 'signe|' + w;
var valtype = document.getElementById(indtype).value;
valtype = valtype.trim();
var indodd = v + 'odd|' + w;
var valodd = document.getElementById(indodd).value;
valodd = valodd.trim();
encoded = encoded + valtype + '<e>' + valodd + '<e>';
resnumber++;
}
encoded = encoded + '|';
}
encoded = encoded + '<results>';
for (t = 0; t < resnumber; t++) {
encoded = encoded + '<res>';
}
答案 0 :(得分:1)
您不能简单地将其转换为PHP,因为它处理来自DOM元素的值。 PHP和Javascript之间的语法非常相似,从您的示例列表中我可以向您展示它们的对应物:
var encoded = '';
$encoded = '';
var resnumber = 0;
$resnumber = 0;
for(v=1;v<=evnumber;v++) {
for( $v=1; $v<=$evnumber; $v++ ) {
var indcode = v + 'code';
$indcode = $v + 'code';
var valcode = document.getElementById(indcode).value;
// This is an example of something you can't do with PHP, because it doesnt have access to the document unless your parsing it with DOMDocument or something.