• <tfoot id='irAci'></tfoot>

      <small id='irAci'></small><noframes id='irAci'>

      <i id='irAci'><tr id='irAci'><dt id='irAci'><q id='irAci'><span id='irAci'><b id='irAci'><form id='irAci'><ins id='irAci'></ins><ul id='irAci'></ul><sub id='irAci'></sub></form><legend id='irAci'></legend><bdo id='irAci'><pre id='irAci'><center id='irAci'></center></pre></bdo></b><th id='irAci'></th></span></q></dt></tr></i><div id='irAci'><tfoot id='irAci'></tfoot><dl id='irAci'><fieldset id='irAci'></fieldset></dl></div>
        <bdo id='irAci'></bdo><ul id='irAci'></ul>

      1. <legend id='irAci'><style id='irAci'><dir id='irAci'><q id='irAci'></q></dir></style></legend>

        检查字符串是否以 PHP 中的数字结尾

        Check if a String Ends with a Number in PHP(检查字符串是否以 PHP 中的数字结尾)

        <legend id='gdtj7'><style id='gdtj7'><dir id='gdtj7'><q id='gdtj7'></q></dir></style></legend>
      2. <tfoot id='gdtj7'></tfoot>

          • <bdo id='gdtj7'></bdo><ul id='gdtj7'></ul>

            <i id='gdtj7'><tr id='gdtj7'><dt id='gdtj7'><q id='gdtj7'><span id='gdtj7'><b id='gdtj7'><form id='gdtj7'><ins id='gdtj7'></ins><ul id='gdtj7'></ul><sub id='gdtj7'></sub></form><legend id='gdtj7'></legend><bdo id='gdtj7'><pre id='gdtj7'><center id='gdtj7'></center></pre></bdo></b><th id='gdtj7'></th></span></q></dt></tr></i><div id='gdtj7'><tfoot id='gdtj7'></tfoot><dl id='gdtj7'><fieldset id='gdtj7'></fieldset></dl></div>

            <small id='gdtj7'></small><noframes id='gdtj7'>

                <tbody id='gdtj7'></tbody>

                1. 本文介绍了检查字符串是否以 PHP 中的数字结尾的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在尝试实现以下功能.最好在这里使用某种类型的正则表达式吗?我也需要获取号码.

                  I'm trying to implement the function below. Would it be best to use some type of regex here? I need to capture the number too.

                  function endsWithNumber($string) {
                    $endsWithNumber = false;
                  
                    // Logic
                  
                    return $endsWithNumber;
                  }
                  

                  推荐答案

                  $test="abc123";
                  //$test="abc123n";
                  $r = preg_match_all("/.*?(d+)$/", $test, $matches);
                  //echo $r;
                  //print_r($matches);
                  if($r>0) {
                      echo $matches[count($matches)-1][0];
                  }
                  

                  正则表达式解释如下:

                  .*?- 这将从一开始就占用字符串中的所有字符,直到也找到后续部分的匹配项.

                  .*? - this will take up all the characters in the string from the start up until a match for the subsequent part is also found.

                  (d+)$ - 直到字符串末尾的一位或多位数字,已分组.

                  (d+)$ - this is one or more digits up until the end of the string, grouped.

                  没有 ?在第一部分中,只有最后一个数字将在第二部分中匹配,因为它之前的所有数字都会被 .* 占用.*

                  without the ? in the first part, only the last digit will be matched in the second part because all digits before it would be taken up by the .*

                  这篇关于检查字符串是否以 PHP 中的数字结尾的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  DeepL的翻译效果还是很强大的,如果我们要用php实现DeepL翻译调用,该怎么办呢?以下是代码示例,希望能够帮到需要的朋友。 在这里需要注意,这个DeepL的账户和api申请比较难,不支持中国大陆申请,需要拥有香港或者海外信用卡才行,没账号的话,目前某宝可以
                  PHP通过phpspreadsheet导入Excel日期,导入系统后,全部变为了4开头的几位数字,这是为什么呢?原因很简单,将Excel的时间设置问文本,我们就能看到该日期本来的数值,上图对应的数值为: 要怎么解决呢?进行数据转换就行,这里可以封装方法,或者用第三方的
                  mediatemple - can#39;t send email using codeigniter(mediatemple - 无法使用 codeigniter 发送电子邮件)
                  Laravel Gmail Configuration Error(Laravel Gmail 配置错误)
                  Problem with using PHPMailer for SMTP(将 PHPMailer 用于 SMTP 的问题)
                  Issue on how to setup SMTP using PHPMailer in GoDaddy server(关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题)

                  <legend id='GffVJ'><style id='GffVJ'><dir id='GffVJ'><q id='GffVJ'></q></dir></style></legend>
                    <bdo id='GffVJ'></bdo><ul id='GffVJ'></ul>

                        <tbody id='GffVJ'></tbody>

                        <tfoot id='GffVJ'></tfoot>

                            <i id='GffVJ'><tr id='GffVJ'><dt id='GffVJ'><q id='GffVJ'><span id='GffVJ'><b id='GffVJ'><form id='GffVJ'><ins id='GffVJ'></ins><ul id='GffVJ'></ul><sub id='GffVJ'></sub></form><legend id='GffVJ'></legend><bdo id='GffVJ'><pre id='GffVJ'><center id='GffVJ'></center></pre></bdo></b><th id='GffVJ'></th></span></q></dt></tr></i><div id='GffVJ'><tfoot id='GffVJ'></tfoot><dl id='GffVJ'><fieldset id='GffVJ'></fieldset></dl></div>

                            <small id='GffVJ'></small><noframes id='GffVJ'>