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

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 :)
 
I don't see why not, but am lost at a few commands... (not that fluent in the more complicated PHP)

cleanUpdate is ??
 
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:
 
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.
 
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
 
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
 
@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. :)
 
Back
Top