check string in variable using PHP.help..thanks.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • perhapscwk
    New Member
    • Sep 2007
    • 123

    check string in variable using PHP.help..thanks.

    If i use sql statement such as

    select * from table1, then store all the product code
    as $prodcode.

    Now i want to write something, such as
    $newprod2 = substr($prodcod e,2)
    then it will store all into $newprod2 but all data only with the first 2 char.

    But if i want to ..for example, for all productcode, if there is POxxx or xxPOxx, etc. If there is a PO in product code, then change it to a new code such as
    "FGFGF".

    how to do this?


    thanks.
  • hsriat
    Recognized Expert Top Contributor
    • Jan 2008
    • 1653

    #2
    You may find str_replace useful.

    Comment

    • perhapscwk
      New Member
      • Sep 2007
      • 123

      #3
      no..any other methods?

      Comment

      • hsriat
        Recognized Expert Top Contributor
        • Jan 2008
        • 1653

        #4
        Originally posted by perhapscwk
        no..any other methods?
        preg_replace (what else can I say?)

        Can suggest something else if you explain it a bit.

        Comment

        • TheServant
          Recognized Expert Top Contributor
          • Feb 2008
          • 1168

          #5
          Originally posted by perhapscwk
          no..any other methods?
          Lol, yeah you need to tell us why you can't use our solutions, and give some parameters for a solution. None of us want to waste time just guessing so we need some detail.

          Comment

          Working...