您可以使用explode()将 the 转换string为 an array,然后得到您想要的。像这样-$example = '1284&kec=220107&prop=220000';$ex = explode("&kec", $example); // convert it to array where $kec is found$value = $ex[0]; // output: 1284 // the first key will hold the value before $kec$example2 ='11&kec=2332&prop=563454';$ex = explode("&kec", $example2);$value = $ex[0]; // output: 11