Jump to content

M84

New Members
  • Posts

    3
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

M84's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I have to split an email that is received everyday, with a set of rules. This is an example of the email: A N K U N F T 11.08.15 *** NEUBUCHUNG *** 11.08.15 xxx xxx X3 2830 14:25 17:50 18.08.15 xxx xxx X3 2831 18:40 F882129 dsdsaidsaia F882129 xxxyxyagydaysd «CUT HERE» A N K U N F T 18.08.15 *** NEUBUCHUNG *** 11.08.15 xxx xxx X3 2830 14:25 17:50 18.08.15 xxx xxx X3 2831 18:40 F881554 ZXCXZCXCXZCCXZ F881554 xcvcxvcxvcvxc F881554 xvcxvcxcvxxvccvxxcv «CUT HERE» 11.08.15 xxx xxx X3 2830 14:25 17:50 18.08.15 xxx xxx X3 2831 18:40 F881605 xczxcdfsfdsdfs F881605 zxccxzxzdffdsfds «CUT HERE» So it basically has to be cut whenever the last F999999 appears ( where 9 can be any number). I tried the solution on a regex101.com - https://regex101.com/r/rT0yQ1/1 and it worked, however when I do this on my server with php and sending the email text by post is doesnt. I paste the email text to a textbox and then press a button that then divides it. Here is my code: file teste.php: <form method="post" action="teste2.php" enctype="multipart/form-data"> <textarea name="email" cols="110" rows="30" id="email"></textarea> <br /> <input type="submit" value="Dividir" /> </form> file teste2.php <?php $str = $_POST['email']; $re = "/(?:\sF\d+.*?\n\n)(\n)/"; $subst = ">>CUT HERE>>"; $result = preg_replace($re, $subst, $str); echo $result; ?> I try this here: https://3v4l.org/mqrJc2 and it works. It seems like a problem when I send the text in a textarea by post the newlines disappear, because when I use a string it works. Can anyone help me? Thank you very much in advance!
  2. I'm developping an application in flash and when I create an image I want to save the info of that image in a xml file. After searching it seems that doing that would be better with php. But I'm kinda of a noob in terms of php and xml. So I was thinking of sending the images name, height and width to php and then edit a xml file that already exists. the xml file has a very simple structure: <gallery> <image path="images/flor.JPG" width="96" height="96" /> <image path="images/palmeiras.JPG" width="96" height="97" /> </gallery> I already tried SimpleXML, but I dont know how to edit the actual xml file. This is the php code I have now: <?php if (file_exists('images.xml')) { $sxo = simplexml_load_file('images.xml'); $new_image = $sxo->addChild("image"); $new_image->addAttribute("path","image.jpg"); $new_image->addAttribute("width","97"); $new_image->addAttribute("height","100"); var_dump($sxo); } else { exit('Failed to open test.xml.'); } ?> It reads my xml file, and adds a new child, but how do I update that info on the actual xml file? Can somebody please help me?
×
×
  • 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.