是否有与 PHP explode() 等效的 JavaScript?

javascriptobject oriented programmingfront end technology

与 PHP explode() 等效的 JavaScript 是 split()。要获取第一个冒号后的数据,请尝试运行以下代码。

示例

<!DOCTYPE html>
<html>
   <body>
      <script>
         var str = '087000764008:Rank:info:result';
         var arr = str.split(":");

         document.write(arr[1] + ":" + arr[2]);
     </script>
   </body>
</html>

相关文章