Jackal Posted March 10, 2009 Report Share Posted March 10, 2009 Ar regulārajām izteiksmēm esmu darbijies ļoti maz, tāpēc nevaru uzraktīt vienkāršu izteiksmi :(. Kods $content = " <div> <div class=\"post\">1<div class=\"bottom\"></div> <div class=\"post\">2<div class=\"bottom\"></div> <div class=\"post\">3<div class=\"bottom\"></div> <div class=\"post\">4<div class=\"bottom\"></div> <div class=\"post\">5<div class=\"bottom\"></div> </div> "; preg_match_all("/<div class=\"post\">(.*)<div class=\"bottom\"><\/div>/s", $content, $array); print_r($array); Izvada Array ( [0] => Array ( [0] => <div class="post">1<div class="bottom"></div> <div class="post">2<div class="bottom"></div> <div class="post">3<div class="bottom"></div> <div class="post">4<div class="bottom"></div> <div class="post">5<div class="bottom"></div> ) [1] => Array ( [0] => 1<div class="bottom"></div> <div class="post">2<div class="bottom"></div> <div class="post">3<div class="bottom"></div> <div class="post">4<div class="bottom"></div> <div class="post">5 ) ) Tas nav gluži tas ko man vajadzēja. Gribēju, lai šis (<div class=\"post\">1<div class=\"bottom\"></div>) tiek ņemts katrs atsevišķi. Ir vajadzība dabūt ārā tos skaitļus, kas atrodas starp <div class="post"> un <div class="bottom"></div>. Kā parezi būtu jāraksta šī regulārā izteiksme? Quote Link to comment Share on other sites More sharing options...
bubu Posted March 10, 2009 Report Share Posted March 10, 2009 Pieliec U galā - preg_match_all("/.../sU", ...); Quote Link to comment Share on other sites More sharing options...
Jackal Posted March 10, 2009 Author Report Share Posted March 10, 2009 Paldies! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.