Jump to content

WillyTheFish

Members
  • Posts

    26
  • Joined

  • Last visited

    Never

Everything posted by WillyTheFish

  1. The String contains a value between the tags aswell "Engagerad", which got stipped aswell. I solved this by using the following regex: $regex_strip_tags = "/<[\/\!]*?[^<>]*?>/"; $result[1][] = preg_replace($regex_strip_tags,'',$snippets[0][$key]);
  2. Hey guys! I tried to use strip_tags() on this string, but the function will return a null-string for some reason? Any idea why, and any suggestion how to solve this? $string = '<Word.Bookmark.Start" w:name="a"/><w:p><w:pPr><w:jc w:val="center"/><w:rPr><w:sz w:val="16"/><w:sz-cs w:val="16"/></w:rPr></w:pPr><w:r><w:rPr><w:rFonts w:ascii="Arial" w:h-ansi="Arial" w:cs="Arial"/><wx:font wx:val="Arial"/><w:b/><w:highlight w:val="light-gray"/></w:rPr><w:t>Engagerad</w:t></w:r><aml:annotation aml:id="0" w:type="Word.Bookmark.End>'; echo strip_tags($string); // returns nothing, nada... thank you
  3. ahh thank god.. works fine with preg_match_all(). First array is trash though, but i can live with that, second one is beautiful thanks alot sasa!!!!!!
  4. nope, unfortunately i cannot use strip_tags... i have to solve this using regex, because i need to determine the position where the data was extracted later on and will be using the same regex twice =/
  5. ops, sorry i'm stupid, forgot to print it right... actually, both elements are incorrect Array ( [0] => "Word.Bookmark.Start" w:name="something"/> <w:r><w:rPr><w:sz w:val="24"/> </w:rPr><w:t>THIS IS THE TEXT I WANT TO EXTRACT!</w:t></w:r><w:r><w:rPr><w:sz w:val="24"/></w:rPr><w:br/> </w:r><aml:annotation aml:id="2" w:type="Word.Bookmark.End" [1] => <w:r><w:rPr><w:sz w:val="24"/> </w:rPr><w:t>THIS IS THE TEXT I WANT TO EXTRACT!</w:t></w:r><w:r><w:rPr><w:sz w:val="24"/></w:rPr><w:br/> </w:r> )
  6. I tested your regex with another file, but that didn't work at all the format is still the same though. But yeah, the second element of the array is correct!
  7. thanks sasa, almost... this regex gives me two arrays: array(2) { [0]=> string(242) ""Word.Bookmark.Start" w:name="something"/> THIS IS THE TEXT I WANT TO EXTRACT! string(147) " THIS IS THE TEXT I WANT TO EXTRACT! " } could you have another look at it? thank you so much!
  8. Well I tried simplexml_load_file() but that resulted in an empty object... but to be honest, i don't know how to do it... any suggestions?
  9. Hey guys, this is probably pretty simple, but I really have a problem with regex. This is the input string: </w:r><w:r><w:rPr><w:b/><w:sz w:val="24"/></w:rPr><w:br/></w:r><w:r><w:rPr><w:b/> <w:sz w:val="24"/></w:rPr><w:br/></w:r><aml:annotation aml:id="2" w:type="Word.Bookmark.Start" w:name="something"/> <w:r><w:rPr><w:sz w:val="24"/> </w:rPr><w:t>THIS IS THE TEXT I WANT TO EXTRACT!</w:t></w:r><w:r><w:rPr><w:sz w:val="24"/></w:rPr><w:br/> </w:r><aml:annotation aml:id="2" w:type="Word.Bookmark.End"/><w:r><w:rPr><w:sz w:val="24"/></w:rPr><w:br/></w:r><w:r><w:rPr> <w:sz w:val="24"/></w:rPr><w:br/></w:r><w:r><w:rPr><w:sz w:val="24"/><w:highlight w:val="light-gray"/></w:rPr><w:t>NO MATCH</w:t> I want to match the text between "Word.Bookmark.Start" and "Word.Bookmark.End", but not the tags inbetween. So the match of the RegEx in the example above should be: "THIS IS THE TEXT I WANT TO EXTRACT!" I do not want to extract the text "NO MATCH", since it is not located between "Word.Bookmark.Start" and "Word.Bookmark.End". I wanna gather all matches in an array. Please help! Many thanks
  10. hm okay thanks... to be honest I don't get it... how do I process a .doc file with this library?
  11. Hey guys, any suggestions how i could read and write msWord files without using the COM interface. I need to keep all the formatting intact though... any ideas? many thanks
  12. yeah it's me again.... now I downloaded and tried this script/class and left it unchanged... still doesn't work: http://www.phpclasses.org/package/3553-PHP-Edit-Microsoft-Word-documents-using-COM-objects.html there must be something wrong with my php-settings or my ms Word installation i guess? COM is enabled in phpinfo()! Any suggestions....? I really need to get this to work thanks!
  13. Hey guys, I've been searching the forum, but haven't found a post describing the following problem: I want to Open and Manipulate a word document using the COM class. This is my code so far: $Wrd = new COM("Word.Application"); $DocName = TEMPLATE_DIR.'template.doc'; $Wrd->Application->Visible = True; $WrdDoc = $Wrd->Documents->Open(realpath($DocName)); # do something here $WrdDoc->SaveAs(realpath($DocName)); $Wrd->ActiveDocument->Close(false); $Wrd->Quit(); $Wrd = NULL; There's no problem creating the COM-object, but when i try $WrdDoc = $Wrd->Documents->Open(realpath($DocName)); the browser is either complaining about insufficient memory or will chew on the code for ages... I can see that a temporary word file is created, so it seems that the document has been opened... still, the browser is working and working.... can anyone tell me what's going on? Many Thanks!
  14. Hey guys, already posted this problem once, sorry about that, but i was a little unclear in what i wanted to do and still couldn't figure it out on my own. as you see below i have the number 215 which i want to round so that it end with $v1 or $v2, depending on what is closer to it... I want to return 4 possible outcomes in $a,$b,$c and $d... so $a = 145, $b = 195, $c = 245 and $d = 295.... as you see, all of them ending with either $v1 or $v2. I tried to write the code so that it will work with all kinds of numbers, if i change the variables $number, $v1 and $v2, but failed so far... This also needs to work for $number = 4.6, $v1 = 0.5 and $v2 = 0.9 if you get what i mean. $v1 = 45; $v2 = 95; $number = 215; $num_len = strlen(round($number)); $v_len = strlen(round($v1)); $a = (floor($number/pow(10,$num_len-1)) + $v1/pow(10,$v_len)) * pow(10,$num_len-1); $b = (floor($number/pow(10,$num_len-1)) + $v2/pow(10,$v_len)) * pow(10,$num_len-1); $c = (ceil($number/pow(10,$num_len-1)) + $v1/pow(10,$v_len)) * pow(10,$num_len-1); $d = (ceil($number/pow(10,$num_len-1)) + $v2/pow(10,$v_len)) * pow(10,$num_len-1); please help so i can move on thanks!
  15. hi, sure =) i want the value $number to END with either $val1 or $val2 so if if $number is 14, and $val1 = 5 and $val2 = 9 i want $number to be rounden to 15, instead of 19, because it's closer to the original value... don't know how to explain it better then that
  16. thanks, but i knew how ceil and floor works.. the thing is, i need to figure out a logic that works in the example i posted above...
  17. round() and ceil() yes, but couldn't figure out how to use them on this... sorry, I'm still a noob
  18. hey guys, need some help with this cause i'm too stupid to figure it out myself: function doRound($number,$val1,$val2) { } I want to round a number ($number) so that it ends with either $val1 or $val2, depending on which one is closest to it. for example $number = 14 $val1 = 5 $val2 = 9 result would be 15 $number = 11 $val1 = 5 $val2 = 9 result would be 9 $number = 8 $val1 = 0.5 $val2 = 0.8 result would be 7.8 you get the point please help!!
  19. Hello everyone.. new to Php and Mysql, so this is probably nothing special for you guys, but it blows my mind right now cause I'm trying to do this using 1 million different loops I have two tables which are located in different databases. Looks pretty much like this: Table: "source_table" Database: "db1" IDArticle_noProduct_namePrice 1989898radiator23.50 2234255transformator19.20 3142736horse99.99 Table: "target_table" Database: "db2" IDHeightArticleWeight 112m78631214kg 217m32154139kg 322m23425523kg What i need to do: I've got an array containing all column names for 'source_table' that shall be imported into 'target_table'. Let's say these columns are 'Product_name' and 'Price'. Now i want the script to fetch the value in Product_name' and 'Price' where the value of 'Article_no' (in source_table) matches the value of 'Article' (in target_table). For the example above this would mean: create columns 'Product_name' in 'target_table' and insert the value 'transformator' (from 'source_table') into 'target_table' where Article = 234255. Same for the column 'Price'. Ignore records where Article and Article_no don't match. Please help! thanks!
  20. Hello everyone! I have this RegEx (used it in a JavaScript) is would like to use in preg_match, but it won't work /'|"|´|`*/img Tried to 'translate' it and came up with $test = preg_replace('/\/\'|\"|´|`*\/img/','',$test); which didn't do the trick... any suggestions? thanks
  21. Okay, I know this is extremely simple but I tried the return() function and all that, but it just won't work... How do I pass a variable or an array from a function to the global scope? <?php function db_getcol($db_database,$db_tablename) { $db_fields = mysql_list_fields($db_database,$db_tablename); $db_columns = mysql_num_fields($db_fields); for ($n=0;$n<=$db_columns-1;$n++) { $field_array[] = mysql_field_name($db_fields,$n); } return $field_array; } var_dump($field_array); ?> as you see, I'm trying to get a var_dump() of $field_array, which is defined within the function... Thanks in advance
  22. thanks guys, almost got it figured out now.... mysql_query("INSERT INTO `".$db_tablename."` ".$test1." VALUES ".$test2.""); $test2 contains the string: (123456', '12,45', '10', '11,45', 'Buy me!') my error msg: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '', '12,45', '10', '11,45', 'Don't Buy me)' at line 1(654321', '10,11', '90', '9,11', 'Buy Me!) so i figured the error must have something to do with the format at '12,45' ... how do i make mysql swallow it?
×
×
  • 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.