deleting characters after comma

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • cosmicstar23@gmail.com

    deleting characters after comma

    I have a string:

    "WorldWatch , Tokyo"

    Is there anyway I can delete everything after the comma including the
    comma itself? Keep in mind that everything atfer the comma is
    generated dynamically!

    Thanks!
  • Geoff Muldoon

    #2
    Re: deleting characters after comma

    In article <1b01c7ba-d6e8-47fe-9af7-
    b1557537022b@m3 6g2000hse.googl egroups.com>, says...
    I have a string:
    >
    "WorldWatch , Tokyo"
    >
    Is there anyway I can delete everything after the comma including the
    comma itself? Keep in mind that everything atfer the comma is
    generated dynamically!
    Read the manual on the functions stripos and substr.

    Geoff M

    Comment

    • Claudio Corlatti

      #3
      Re: deleting characters after comma

      On 5 ago, 20:04, cosmicsta...@gm ail.com wrote:
      >
      "WorldWatch , Tokyo"
      >
      Is there anyway I can delete everything after the comma including the
      comma itself? Keep in mind that everything atfer the comma is
      generated dynamically!
      >
      Thanks!
      as Geoff said, to do that, you should use strpos and substring
      an example:
      $str = 'WorldWatch, Tokyo';
      $positionOfTheC omma = strpos($str,',' );
      $strWithoutTheC omma = substr($str, 0, $positionOfTheC omma);

      Comment

      • C. (http://symcbean.blogspot.com/)

        #4
        Re: deleting characters after comma

        On Aug 6, 12:12 am, Geoff Muldoon <geoff.muld...@ trap.gmail.com>
        wrote:
        In article <1b01c7ba-d6e8-47fe-9af7-
        b15575370...@m3 6g2000hse.googl egroups.com>, says...
        >
        I have a string:
        >
        "WorldWatch , Tokyo"
        >
        Is there anyway I can delete everything after the comma including the
        comma itself? Keep in mind that everything atfer the comma is
        generated dynamically!
        >
        Read the manual on the functions stripos and substr.
        >
        Geoff M
        ...or strtok, preg_match, explode....actu ally, read all the manual.

        C.

        Comment

        Working...