Extracting a string solution

Source: Internet
Author: User
Extracting a string
How do i put a string
10000000779460 5 10000000779461 One
The data in the OrderNo and orderresult tags are all extracted. Put into two arrays, respectively?
------Solution--------------------
$str = "
 
  
 
  
   
  10000000779460
 
  
 
  
   
  5
 
  
 
  
   
  10000000779461
 "
  
 
  
   
  ;
 
  
htm
Preg_match_all ("/< ([^>]+) > ([^<]+) <\/\\1>/u", $str, $matches);
$out = Array ();
foreach ($matches [1] as $key = + $value) {
$out [$value] = $matches [2][$key];
}
Var_dump ($out);

------Solution--------------------
Not a standard XML output, is it?
$s = " 10000000779460 5 10000000779461 One ";
$a = simplexml_load_string ($s);
Print_r ($a);
------Solution--------------------

XML file Operations
$SIMXML = simplexml_load_file (' Xmlpath ');
Remove OrderNo
erNo = Array ();

{
erNo [] = (string) er; Convert directly to string storage
}
Remove Orderresult
erResult = Array ();

{
erResult [] = (string) $res;//convert directly into string storage, can also be converted to other;
}


Simple XML operation don't know if it's what you want
------Solution--------------------
$s =<<< TXT
10000000779460 5 10000000779461 One
TXT;

$d = Array (' OrderNo ' = ' array_order ', ' orderresult ' = ' arraresult ');
Preg_match_all (' #< (OrderNo
------Solution--------------------
Orderresult) > (. +) #U ', $s, $r);

foreach ($r [1] as $i = $k) ${$d [$k]}[] = $r [2][$i];

Print_r ($array _order);
Print_r ($arraresult);
Array
(
[0] = 10000000779460
[1] = 10000000779461
)
Array
(
[0] = 5
[1] = 11
)

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.