-
Posts
14,780 -
Joined
-
Last visited
-
Days Won
43
Everything posted by .josh
-
$result = checkArray($clamarr, $found); You aren't assigning anything to $found. $found should be the word you are looking for. Either do $found = "enterwordhere"; $result = checkArray($clamarr, $found); or $result = checkArray($clamarr, "enterwordhere");
-
You have to loop through each element of the array and do a substring search. Which is pretty much what gevan's suggestion does. Though, I think I'd probably use stripos instead.
-
so.addVariable\(\"content_video\", \"([^\"]*)\"\);
-
Do you expect only linebreaks and whitespace? As in, no other tags? Just do the same thing as you did with your other pieces. preg_match('{</span>[^<]*<cite[^>]*>([^<]+)</cite>}', $html, $match);
-
Probably not the best way, but... preg_match_all("~\(.+?\)\)~s",$string,$match); print_r($match);
-
I've been using html-kit forever now. Pretty simple. Syntax highlighting. Lots of plug-ins. Remote folder/file viewing/editing. FREE. Only thing I wish it had was collapsible functions, loops, etc...
-
so you want to capture this: Do you want to capture it as just 1 string of info, or each individual (...)? Your example has two sets of those things; will your document have more than 1, and do you want to capture those, as well?
-
I could be wrong, but I doubt he's looking at it like "I'm gonna go talk to this dude because he owes me for storing his stuff in my shed," so why should you look at it like you have to talk to him because of that? There's absolutely no reason you should feel bad about telling him "Dude, stop coming by here at 7a. It's not a good time for me." But.. you refer to him as "guy I used to know." and how he "'chats' about crap." I take it that means you aren't really interested in his friendship? You are not doing him any favors by putting up with him. Better for you to come off as a dick and say "Dude, I know you helped me in the past, but I'm not really into <insert whatever>" or "I'm not really diggin' you" or something. Better that than to sit there and keep lying to him. Just tell him the truth. Tell him you're grateful he let you store your stuff in his shed back in the day, but life moves on, and so should he. He's going to think you're a much bigger ass when he finds out weeks or months or years from now that you really don't like him and you're just "putting up" with him. And he'll feel bad because he'll be like "Damn wtf I've been fooled this whole time." Write him a letter and leave it on his doorstep if you're too chicken to do it to his face. Better even to do that than keep lying.
-
depends. are you trying to match something before it? what do you mean by skip everything till new line? are you trying to match every line that doesn't have it? where is this data coming from and how are you going through each line? Is you data one giant string and by new line you mean every time there's an \n? a <br/>? Is each line an element in an array? In short, you must be a lot more specific.
-
lol why are you using preg_split? preg_split is a regex version of explode. All it does is take a string and split it up into an array, based on a pattern. So for example, if you have this: $string = "What's up, doc? Nothin' much, man..."; and you do this: $string = preg_split("/[\s.,_\"\'\%\>\<?!-]/", $string); You're going to end up with this: Array ( [0] => What [1] => s [2] => up [3] => [4] => doc [5] => [6] => Nothin [7] => [8] => much [9] => [10] => man [11] => [12] => [13] => ) Unless you are wanting your data to be a specific format (like for instance, the data is a username and you only want it to contain alphanumeric characters), the goal should be to escape characters, not remove them. Otherwise, you're going to find yourself storing a whole lot of swiss cheesed data.
-
[SOLVED] Need to filter out user input to only alphanumeric and spaces
.josh replied to Xerxes1's topic in PHP Coding Help
As DW mentioned, there's no point in mysql_real_escape_stringing after the regex. Leaving it in there "just in case, just to be safe" is superstitious. It's like doing "<b><b>bold</b></b>" twice for good measure, just in case a letter happens to slip through the first <b>...</b>. -
[SOLVED] Need to filter out user input to only alphanumeric and spaces
.josh replied to Xerxes1's topic in PHP Coding Help
you forgot the numbers darkwater. He said alphanumeric. $string = preg_replace("~[^\w ]~","",$string); -
then just do if ($string != "PLAIN") { // string not plain, do something } else { // string is plain, do something } Yes, straight string comparison is faster than regex.
-
okay so then you can just do this: $list = array('PLAIN','K_IF','K_ELSE','K_ENDIF'); if (!in_array($string, $list)) { // string is not one of those things, do something } else { // string is one of those things, do something }
-
Okay but are those "keywords" the only thing in the string like "PLAIN" "K_IF" etc.. or are they just one piece of a string like "PLAIN blahblahlbha" "blah PLAIN blahblah" And again, are you trying to retrieve something from somewhere or are you simply trying to find out whether it's true or not.
-
You are only getting 1 or 0 because preg_match returns a true on successful match, false on no matches when you assert it in a condition like that (or assign it to a var). Actual results would be put into the 3rd argument of preg_match. Beyond that....be more specific. Are you wanting to dump out the contents of $string if it is not "PLAIN" or if it does not contain "PLAIN" in it somewhere? Or are you simply trying to find out whether it is or contains "PLAIN"?
-
Angry about what? Who's angry? And who are these other people you talk about? In other words: I'm sorry? Post was meant for OP, sorry. Also, "they" refers to the people who "fail to use proper english."
-
I do not feel that we should strictly enforce some kind of "standard," in this regard. If the stars don't line up for you, then don't post. Don't get angry about it. Who are they to you? How have they wronged you?
-
If I'm not mistaken, myspace offers up access to things like that, for developers. People generally use it to make apps like mafia wars or whatever, but it's there. I'd go to myspace.com and look around for the developers section.
-
like zen cart or or cubecart?
-
I pick ; over & for the same reason I pick skinny chicks over fat chicks.
-
See look. Not very pretty but a couple lines of code is all it really takes. Couple more lines of code for multi-colored highlighting (for multiple group captures). Throw on some ajax for 'realtime' highlighting. Use some css to make it look pretty. Boom, you're done. <form action = '' method = 'post'> Pattern:<br/> ~<input type = 'text' name = 'pattern' size= '55' value = '<?=$_POST['pattern']?>' />~ <input type = 'text' name = 'modifiers' size = '2' value = '<?=$_POST['modifiers']?>' /><br/> Subject:<br/> <textarea name = 'subject' cols = '50' rows = '10'><?=$_POST['subject']?></textarea><br/> <input type = 'submit' value = 'submit'> </form> <?php if ($_POST['pattern'] && $_POST['subject']) { $pattern = $_POST['pattern']; $subject = $_POST['subject']; $m = trim($_POST['modifiers']); $hSubject = preg_replace("~$pattern~$m","<font color = 'gray'>|</font><font style='background-color: yellow'>$0</font><font color = 'gray'>|</font>",$subject); echo nl2br($hSubject); } ?>
-
Dell has a tendency to have their computers manufactured so that you can only upgrade hardware through them. First thing I would do is check to make sure your motherboard has regular IDE or SCSI interfaces instead of some proprietary Dell crap.
-
btw to add on to what nrg_alpha said... by 'delimiter' he means that they signify the start and end of your pattern. The reason why you need them is because with php (and a lot of other languages), modifiers are parsed from withing the string, so php has to know where the actual pattern starts and ends, and it looks at what is outside of the delimiters for the modifiers (like 'i' for case insensitive matching, etc..) for example: ~[a-zA-Z]~ would match a lowercase or uppercase letter. But you can do the same thing with this: ~[a-z]~i but note that the i modifier would not just apply to that class; it would apply to everything else in your pattern, as well.