Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

get

Name: Anonymous 2007-09-26 7:42 ID:SfYmqN50



<?php
function getStrsBetween($s,$s1,$s2=false,$offset=0) {
    /*====================================================================
    Function to scan a string for items encapsulated within a pair of tags

    getStrsBetween(string, tag1, <tag2>, <offset>

    If no second tag is specified, then match between identical tags

    Returns an array indexed with the encapsulated text, which is in turn
    a sub-array, containing the position of each item.

    Notes:
    strpos($needle,$haystack,$offset)
    substr($string,$start,$length)

    ====================================================================*/

    if( $s2 === false ) { $s2 = $s1; }
    $result = array();
    $L1 = strlen($s1);
    $L2 = strlen($s2);

    if( $L1==0 || $L2==0 ) {
        return false;
    }

    do {
        $pos1 = strpos($s,$s1,$offset);

        if( $pos1 !== false ) {
            $pos1 += $L1;

            $pos2 = strpos($s,$s2,$pos1);

            if( $pos2 !== false ) {
                $key_len = $pos2 - $pos1;

                $this_key = substr($s,$pos1,$key_len);

                if( !array_key_exists($this_key,$result) ) {
                    $result[$this_key] = array();
                }

                $result[$this_key][] = $pos1;

                $offset = $pos2 + $L2;
            } else {
                $pos1 = false;
            }
        }
    } while($pos1 !== false );

    return $result;
}
?>

lol web developers.

Name: Anonymous 2007-09-26 7:48 ID:lXrckt3x

NO EXCEPTIONS

Name: Anonymous 2007-09-26 7:51 ID:Heaven

this is a thread about: get

Name: Anonymous 2007-09-26 7:56 ID:Heaven

never 4get

Name: Anonymous 2007-09-26 8:18 ID:Heaven

sage for PHP

Name: Anonymous 2007-09-26 9:21 ID:Heaven

sage for AWESOME

Name: Anonymous 2007-09-26 11:37 ID:syMK0DvE

But what does it doooo?

Name: Anonymous 2007-09-26 11:42 ID:38e4l2hs

Haha, holy shit.

Actually, I've bumped into people who (honest to god!) claimed they'd rather write ten pages of code rather than one line of regex.

Suffice to say, all of them were complete ignorant mouth-breathers.

Name: Anonymous 2007-09-26 11:44 ID:ovav2YoD

>>8 I'm a mouth  breather, asshole!

Name: Anonymous 2007-09-26 11:49 ID:Mfe/TAE/

Jesus fucking christ, how fucking stupid are people.

REGEXP MOTHERFUCKER, DO YOU USE IT?

Fuck, if you don't want to use regexp, do the next best thing -- USE THE FUCKING DOM. Sure, it isn't exactly lightweight, but it does what you want to do in a fraction of the code.

This is what's wrong with all these idiot programmers anymore. They think the best way to solve the solution is by hand. PROTIP -- other people are much fucking smarter than you are -- the people who write the fucking libraries aren't going to fuck up trivial shit.

Name: Anonymous 2007-09-26 14:06 ID:lXrckt3x

the people who write the fucking libraries aren't going to fuck up trivial shit.
This is PHP we're talking about.

Name: Anonymous 2007-09-26 18:40 ID:52fMGFpN

>>8
Wow, what a morans. I'd rather write ten pages of regex rather than one line of code.

Seriously though, anyone who's scared of PCRE fails hard; if he can't understand such a simple and useful tool, I shudder to think what he'll do to the project.

>>11
Lol. But PHP's preg_* is an interface to libpcre, a high quality Perl-Compatible library. It works great.

Name: Anonymous 2009-08-17 0:12

Lain.

Name: Anonymous 2012-06-25 23:02

鉱㈙陙頹恣镡祹剆噁砣ᙥ鍔⌠煳甡偰顴✣蕰嚆茴ᤗ䜵♒䈑鍔鄈ᡖ衑疅酀㜶ئ癁剴襒蔕ኅ嘀đܒ㝢礄唀舐ↅけ坉←钉㥗࠱ᖒ餓␸䥤⡇嘨㕹耠㆓攷礇ᅶ᝹㝃㐩
攈蚙顦ₙؑ塄㘹戩憇螘հ耆瀳ሑ䦔戰ㅣ褃蠱ΐ㙔⁳╨愤傁扣䈈鐰ᡵ䕳戠硈⦂⡄琵鎂睉憐蔢ᥳ摆醔妔锢餲楨ၑ摦礠ᕶħ犓䄵襒䖓⠉䆆࠹饰匀疕䑉ℓㅹچ挂䑒䎅螕震ކ蔧ॅ̣〕ᑔ䡲䖀斈Цᙸ㉰┖療ᜈ朖颔坦饢ʉ蠅रᕥ぀蚆㝳愓⥖␐䥤ॆғ冑☁恘⡨ᆆ杅畳ɘᔨ蔧▄执•琵ݡ噤‣蔘蜗䝩ݱ茔⤨ˆ卅牀褅㘔ፘ㚂夷㔐頗㉩瑨䕘楢⥣玂ܦᜂ薙᝖㙉ހ锈ɘ鄤ɉ⡂․萒➐昅ݑ䎂⍓偗兹頒ቴᥱࡒ敤䙐礠ّ鎅⥦熉蒐匳ن顰茳撔䉱✃䚖钁祁፩晐圃⤹㈘艘႖㠸い࠰ᄢ朄ᡆᄱ摳䙷霴晸㉨膀劃␦ሷ䍓礥(Җ䉱畂陂┠戕❅褗奔噉ᜈ砈攲錄㉂噹⠦蝈㤆ᔔ₀ش醉

Don't change these.
Name: Email:
Entire Thread Thread List