Jump to content

klyxmaster

New Members
  • Posts

    6
  • Joined

  • Last visited

    Never

Everything posted by klyxmaster

  1. THAT is a very interesting approach.. if I cannot get this preg_figured out, I may do that. Just a quick description the basic page has 1 game features displays images, details, downloads vids etc... the subgame are other games similar or related and at the most there will never be more than 9 or 10 shown. thats why I have not taken your approach yet. It does parse a separate html file that has all the imaga, links descriptions etc... once the tag is found. just right now it doesnt see that tag (yet) thanks!!
  2. ok I like your suggestion (at least i know im going in the right direction) so I went looking at the preg_match here is what I have so far: btw: $html_file is from $html_file = file( ) $field is an array of predefined tags. [code]if( preg_match("/{".$field."[1-9]?}/",$html_file) )[/code] now the page displays correctly and parses all the defined tags just fine, but still will not act on the SUBGAMEx so in the "case" section I added this [code]case preg_match("/{SUBGAME[1-9]?}/",$html_file): [/code] again all other tags are addressed correctly, but still ignores SUBGAMEx Am I still close? or am I way off now :-) ps I forgot to mention is that some of the tags are actually functions. other tags are just replacesments such as SITENAME, AUTHOR etc.. and other tags like GENRE for example call up funtions (to display a bullet list as int he GENRE example) So i have a oneliner to take care of all the replacemnt text and I use a SWITCH to check on triggers that launch a function (prob doing the hardway) that is why there is a if/then check - because that is checking for keywords that are used in functions, once those are checked the program acts on the regular string replacement.
  3. I finished a template engine, its tiny, needed it for a small project. so with that in mind I am stuck on adding a new section that is not going well. tag: {subgame} this will show the layout of a particular game - works fine yippe! but that is just for one game. so now I am changing it to show more than one, and I cannot use that tag over, due to the way "str_replace" works (changes all in one swoop) so I thought doing it this way 2nd Method: {subgame1} {subgame2} {subgame3} etc... the search is: where field is one of the triggers (in this case SUBGAME) if (strstr( '{'.$field.'}",$html_str) ) works fine for the first one, but obviously ignores the 2nd method I tried preg_match - but i know i am missing something, because I cannot get it to work. and ideal way would be the fnmatch( as of 5.3 its available for windows now) but only supports up to 260 characters - not good for website So what I am looking for: psuedo code: if ( '{'.$field.'[optional digits]}' ) { do code here } I know preg_match seems to be the way but cant get it to see the numbers and if it does, it misses the origianl game, or worse crashes.
  4. I agree with the "file" method. see my new post above. much cleaner and I was able to plug it into a function
  5. OK, Im wayyyyyyy too impatient (which can be a good thing ) I kept looking and tried a different method. the following seems to work perfectly and its shorter!! function updateTextRec($orig_filename,$data) { ##-- Put the $orig_filename in an array $data_file = file($orig_filename); ##-- Loop through the new array foreach($data_file as $line_num => $aline) { ##--Cycle through the user $data for a match foreach($data as $field => $value) { $field = str_replace("_",".",$field); if(strstr($aline,$field)) { $data_file[$line_num] = $field." = ".$value."\n"; } } } ##-- Save it $save_file = implode("",$data_file); $fp = fopen($orig_filename,"w"); fwrite($fp,$save_file); fclose($fp); Original idea from : http://php.bigresource.com/Track/php-G1NzcoJB/
  6. Ok i have been working on this for a day+ now. here is my delema simple .ini text file. when a user makes a change (via html form) it makes the correct adjustments. problem is the newline issue 1. if i put a "\n" at the end (when using fputs) works great, except everytime they edit the file it keeps adding a new line (i.e. 10 edits there are now 10 blank lines!!!!) 2. if i leave off the "\n" it appends the next "fgets" to that lilne making a mess ##-- Loop thruoght the ORIGINAL file while( ! feof($old)) { ##-- Get a line of text $aline = fgets($old); ##-- We only need to check for "=" if(strpos($aline,"=") > 0 ) { ##-- Write NEW data to tmp file fputs($tmp,$info[$i]." = ".$rslt[$i]."\n"); $i++; } ##-- No Match else { fputs($tmp,$aline."\n"); }//Checking for match }//while eof(old) what in the world is making this such a big deal. i dont remember having this issue in the past I tried opening with w+, and just w on the temp file a typical text line would be some fieldname = some value the scipt cycles through the file ignoring comments that are "#" ps the tmp file will overwrite the origianl once complete all i really want to know is WHY i cant get the newline to work, and what is the suggested fix EDIT: i just tried PHP_EOL and it still appends another newline
×
×
  • 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.