Jump to content

tox_yray

Members
  • Posts

    7
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

tox_yray's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Ok, here is the problem: I have this little bit of code: [code]<?php $lole = array('rouge', 'vert', 'bleu'); $STRING = "Le ciel est $$!!WIDTH2++--"; echo preg_replace("/\\$\\$!!WIDTH(\\d+)\\+\\+--/", "\\1", $STRING); ?>[/code] The Regex is proper as the script echoes "Le ciel est 2". However, I would like him to echo "Le ciel est bleu" (where "bleu" is the index 2 of array $lole... You get the picture...) I tried many different solutions but none seem to work. Here is what I've tried: [code] echo preg_replace("/\\$\\$!!WIDTH(\\d+)\\+\\+--/", $lole["\\1"], $STRING); echo preg_replace("/\\$\\$!!WIDTH(\\d+)\\+\\+--/", "$lole[\\1]", $STRING); echo preg_replace("/\\$\\$!!WIDTH(\\d+)\\+\\+--/", $lole[\\1], $STRING); [/code] Thanks for any help you can provide, Bruno M-A.
  2. Hi, I have a little problem converting Word generated RTF document to HTML via PHP: Here is a part of a test file: [code]{\insrsid14898988 \par Ceci, il n\rquote y en a }{\insrsid13044712 p}{\insrsid14898988 as.\par }[/code] should output: Ceci, il n'y en a pas. outputs: Ceci, il n'y en a p as. Reason: "pas" is splitted because it was modified from "Pas" to "pas" from a save to another and there is a space between "insrsid" and "as" that ISN'T MEANT to be there. Now here is another part: [code]{\insrsid12341801 avec sans barque}{\insrsid6517974 okok}[/code] should output: avec sans barque okok outputs: avec sans barque okok Reason: Just normal behavior. The space between "insrsid" ans "okok" is MEANT to be there. Now, my question is, has anyone worked with RTF enough to know a way of telling whether that space should be in the output? Anyone knows how Microsoft Word processes it (that might help me process it myself)? Thanks a whole lot for any input, Bruno M-A.
  3. I am not sure wether this is what you want, but at the moment of printing the values, you could just do a switch that would echo either "yes" or "no" depending on the letter it received as a $case... You could even functionalize it for better readablility: [code] function ynchar_to_yesnostring($param) {   switch($param)   {      case "y":      case "Y": $out = "yes"; break;      case "n":      case "N": $out = "no"; break;      default: $out = ""; break;   }   return $out; }[/code] An example use of this would be that: [code] $enum = "Y"; echo ynchar_to_yesnostring($enum); //would print yes [/code] You might want to make the function name shorter though if you use it often.
  4. In this case, just do that: [code] $id = (value you want); include(whatever relative path you want WITHOUT url variables); [/code] include(); will just make a big php page with ALL the code before interpreting it, so $id or the "parent" will be recognized by included pages. As easy as that.
  5. Thanks a lot, it works like a charm. However, for future reference, you have to make sure you write your search array like this: [code]$search = array("\r", "\n");[/code] Escaping the slash (\\) will cause the script to search for the actual string "\r" instead of the char '\r'. Single quotes will auto-escape the slash, so double quotes are required here. Hoping this will help more people around here sometime, Bruno M-A.
  6. Hi, See, I have this massive chunk of code to convert RTF into HTML and I get problems with special characters when their is "something" (other than a space) between the special character and the rest of the word. For example, the flow "\'c9cole Polytechnique de Montr\'e9 al \par." seems to have only a space between the last "é" and "al" and between "al" and "\par" too. However, when I mark, nl2br() and explode the string, here is what is returned on screen: [code] 2078: $$!!CONTROL++--++SPACECHARc9 2079: cole 2080: Polytechnique 2081: de 2082: Montr 2083: $$!!CONTROL++--++CHARe9 2084: al. 2085: $$!!CONTROL++--par [/code] As you can see, <br>s were introduced before and after "al", which means there is a \n and/or \r char there, that I an't see when I print the stream with echo. My goal now is to detect those characters to delete them from the RTF stream I have to interpret. How to do it is where I hit a wall. Any ideas how to do this? Thanks a lot for any input, Bruno M-A.
×
×
  • 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.