Jump to content

yaba

Members
  • Posts

    27
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

yaba's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. May I rephrase my request: How can I get all instances of "blah" that do NOT belong in a URL, i.e. something starting with either http:// or www. Thanks again :)
  2. I was hoping something a lot simpler and less CPU consuming would exist. For the [img] tag, something like: [code=php:0] $blah= ".+?blah.+?"; $text = preg_replace( "#[^(\[img\])]".$blah."[^(\[/img\])]#i", "replaced", $text); [/code] Any feedback on something like this?
  3. I only need to check for two tags: url and img, so some part of the regex could be "\[(img|url)(=.+?)?\]" (I think) I'm not sure what exactly you meant there? Could you post an example? Thanks for replying :D
  4. Hi everyone, could you please tell me how can I get all instances of "blah" that are NOT included in things like [code] [img]...[/img] and [url=http://blah.com]..[/url] [/code] So, the following should not match: [code] [img]asdfa asdf asd blah asdg [/img] [url=aasdf blah]asdfgsdfg[/url] [url=asdf]asdf blah asdf[/url] [/code] while this should match once: [code] [img]asdfa blah asdf[/img] asdfas sdf blah asgf [url=blah]blah[/url] [/code] Thanks! :D
  5. Yup, that did it! Thanks ;) I indeed got confused trying to express myself!  ???
  6. I think your XMLHTTPRequest object send UTF-8 to your php script. In your php script then, you can convert it to your original encoding like this: [code=php:0]iconv("UTF-8","YOUR_ENCODING",$_GET['var'])[/code] and do whatever you want to do with it. When you need to return info from your php script, use XML if you need to return non-ASCII chars, like this: [code] header('Content-Type: application/xml'); $out = '<?xml version="1.0" encoding="ORIGINAL_ENCODING?>' . "\r\n"; $out .= '<report xml:lang="LANG_HERE"><message>'.$message.'</message></report>'; echo $out; [/code]
  7. Make a function like this (it takes as params the article string and its id to build the link): [code=php:0] function fixLength($str, $id){     $maxChars = 50;     if (strlen($str)>$maxChars){         $str= substr($str, 0, $maxChars )."...<br/><a href=\"index.php?article={$id}\">Read more &raquo;</a>";     }     return $str; } [/code]
  8. [code=php:0] <?php echo <<<OUT //put here all that stuff OUT; ?> [/code] make sure there's no white space after <<<OUT and no white space before and after OUT; ;)
  9. I'm not sure you can do this once you call the split() function. What I would do is put the field I want to sort by as the first thing for every line in my file and then sort the $readfile array using one of the... array sort functions (sort, ksort, asort etc), before splitting...
  10. I dodn't quite get the "This product textfield will then change depending on which product page the user is directed to the enquiry form from." bit, but here's a quick example to accomplish the first part: Product view page: [code] <form name="myform" method="post" action="enquiry.php"> <input type="hidden" name="prod_name" value="{$pname}"/> <input type="hidden" name="prod_id" value="{$pid}"/> <input id="btn" type="submit" value="Enquiry"/> </form> [/code] Enquiry page: [code] <form name="myform2" method="post" action="send.php"> <input type="text" value="{$_POST['prod_id']}: {$_POST['prod_name']}"/> </form> [/code] Of course, you need to adjust the variable names. And I would further process the form based on the product id, not its name. The name is only good for the customer's understanding. ;)
  11. A very quick and dirty way of doing this: [code=php:0] $rows = $db->query("my query here"); while ($r = $rows->fetch_assoc()){ $names[] = $r['name']; $ages[] = $r['age']; $sexes[] = $r['sex']; $addresses[] = $r['address']; } $out = "<tr><td>name</td>"; foreach ($names as $n) $out = "<td>".$n[$i]."</td>"; $out .= "</tr>"; $out .= "<tr><td>age</td>"; foreach ($ages as $a) $out = "<td>".$a[$i]."</td>"; $out .= "</tr>"; $out .= "<tr><td>sex</td>"; foreach ($sexes as $s) $out = "<td>".$s[$i]."</td>"; $out .= "</tr>"; $out .= "<tr><td>address</td>"; foreach ($addresses as $a) $out = "<td>".$a[$i]."</td>"; $out .= "</tr>"; echo "<table>{$out}</table>"; [/code] I bet this can be written in a better way, as this is not very efficient. And I haven't run this, maybe there are typos. And the first 2-3 lines assume you are using OO mysqli, you can easily change the way you fetch your rows. Hope this helps ;)
  12. Hello, I need a REGEXP that would match a phrase that contains a word starting with some characters, but would not match a phrase that starts with a word, starting with those chars! ??? Here's an example: search chars = 'abc' 'sss abcsss' (match) 'sss abc abcsss' (match) 'abc sss abcsss' (no match) I thought this (when calling from PHP) would work: [code=php:0]"SELECT * FROM words where wrd REGEXP '^[^({$chars})].*[[:<:]]{$chars}' ORDER BY wrd ASC";[/code] but it doesn't. It will match 'sss abc', but it won't match things like 'sss[b]abc[/b]sfg abc'. Any help greatly appreciated :D
  13. Right, roger that :) Could you elaborate a bit on the pattern you used please? I don't think I've encountered before \p, for example. And those '?<=' and '?=.' bits you used... And correct if I'm worng, the \1 is what is captured by the first set of parentheses, right? I.e. (?<=\p{Z}) I don't quite get it, too advanced for me. Any place I could check these out with examples etc? Couldn't find anything... Or some feedback? Thanks! ;)
  14. So are you saying I should "rebuild" every word I get off the DB to UTF8? That seems a lot of processing :/ Even if I did that, how do I replace say 'α' with $alpha dynamically?
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.