Print Reseller Scheme
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Simple regular expression problem that a monkey who could code could do.

Discussion in 'Website Design Forum:' started by Jazajay, Nov 27, 2009.

  1. Jazajay

    Jazajay Active Member

    Hay peeps been at it for too long and for the life of me I can't get this to work.
    It's like I'm looking at it, it's shouting out at me but I can't see or hear it. :(

    PHP:
    $str=preg_split("/,<br \/>/",cleanUpdate($_GET['update']));
    $var1="";$var2="";$var3="";$var4="";$var5="";$var6="";$var7="";$var8="";
    if(!empty(
    $str[0])){$var1=ucfirst($str[0]);}
    if(!empty(
    $str[1])){$var2=ucfirst($str[1]);}
    if(!empty(
    $str[2])){$var3=ucfirst($str[2]);}
    ...
    What I want to do is split output from a db at ,<br />. But all I'm getting is nothing, no errors, no warnings no output. Simple I know but I just can't see it and yes the data does have several of them in, 8 to be precise, and the cleaning function is not stripping them out either.

    I know I could stick it in a loop but I just want it to work first.

    Cheers for any help. It will be appreciated trust me.
    Jaz :)
     
  2. Renniks

    Renniks Senior Member

    What's the comma for before the <br /> ?

    *see edit*
     
  3. Jazajay

    Jazajay Active Member

    I going crazy but should work right?
     
  4. Renniks

    Renniks Senior Member

    I don't see why not, but am lost at a few commands... (not that fluent in the more complicated PHP)

    cleanUpdate is ??
     
  5. Jazajay

    Jazajay Active Member

    cleanUpdate is a custom cleaning function I built, but it doesn't strip those out.
    But I've taken it out anyway and it's still not outputing.

    What I have at the moment is ~
    PHP:
    $str=preg_split("/,<br \/>/",$_GET['update']);
    $var1="";$var2="";$var3="";$var4="";$var5="";$var6="";$var7="";$var8="";
    echo
    "str1=".$str[1];
    if(!empty(
    $str[0])){$var1=ucfirst($str[0]);}
    if(!empty(
    $str[1])){$var2=ucfirst($str[1]);}
    if(!empty(
    $str[2])){$var3=ucfirst($str[2]);}
    So for example if I echo out str1, as in the snippet above, I get nothing so the problem must be with the expression but to me that looks fine.

    Any ideas what so ever I don't care how out there TBH. :mad:
     
  6. Jazajay

    Jazajay Active Member

    What a moron the get variable was used to pull stuff from the DB which I then need to split, update contains jack as it contains no breaks or commas, just the search criteria for the DB.
    PHP:
    $str=preg_split("/,<br \/>/",$_GET['update']);
    Should have been
    PHP:
    $str=preg_split("/,<br \/>/",$db_variable);
    :mad:

    This thread can now be closed with my flaming blessing. Ahhhhhhhhhhhhhhhh :mad:

    Cheers though renniks thought I was going mad.
     
  7. Renniks

    Renniks Senior Member

    I assumed update was a part of your DB that you were 'getting' and it contained it :) lol (not sure if this is how you would go about it, but didnt know better)

    :p
     
  8. bentzak

    bentzak Senior Member

    this is what this made me think of

    The infinite monkey theorem states that a monkey hitting keys at random on a keyboard for an infinite amount of time will type the complete works of shakespear,

    not calling you monkey, but hopefully one day i will have typed a code so impressive it will make the world invert...

    ...maybe.

    Z
     
  9. Jazajay

    Jazajay Active Member

    @Renniks
    Yeah stupid mistake, always the simple things isn't it.:cry:

    @Bentzak
    I like to think of myself as that monkey TBH, as that is how I code. :)
     

Share This Page