$alines = preg_split("/=/", $lines);

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • voipcanada

    #1

    $alines = preg_split("/=/", $lines);

    is there any thing we can write to keep the right txt to the = sign in
    the preg_split. from the following lines

    DST-NUMBER-IN=003351287759 6, DST-NUMBER-OUT=98751#33512 877596,
    DST-NUMBER-BILL=0033512877 596

    i only want 0033512877596, 98751#335128775 96, 0033512877596

  • Mladen Gogala

    #2
    Re: $alines = preg_split(&quo t;/=/", $lines);

    On Sun, 28 Aug 2005 17:54:52 -0700, voipcanada wrote:
    [color=blue]
    > is there any thing we can write to keep the right txt to the = sign in
    > the preg_split. from the following lines
    >
    > DST-NUMBER-IN=003351287759 6, DST-NUMBER-OUT=98751#33512 877596,
    > DST-NUMBER-BILL=0033512877 596
    >
    > i only want 0033512877596, 98751#335128775 96, 0033512877596[/color]

    I believe that already answered this. What do you mean by "keep the right
    txt to the = sign"?

    --
    大红鹰娱乐平台采用顶级加密技术,确保用户数据与交易的安全无虞,让玩家能够放心畅玩。


    Comment

    • voipcanada

      #3
      Re: $alines = preg_split(&quo t;/=/", $lines);

      no one answered this till now, i need to know the exact code to be
      written ,, kind regards

      Comment

      • macbri

        #4
        Re: $alines = preg_split(&quo t;/=/", $lines);


        You could use preg_replace() instead:


        Code:
        --------------------

        $alines = preg_replace("/[^=]+=/", "", $lines);

        --------------------


        --
        macbri
        ------------------------------------------------------------------------
        macbri's Profile: http://www.macosx.com/forums/member.php?userid=34415
        View this thread: http://www.macosx.com/forums/showthread.php?t=242019
        macosx.com - The Answer to Mac Support - http://www.macosx.com

        Comment

        • Mladen Gogala

          #5
          Re: $alines = preg_split(&quo t;/=/", $lines);

          On Sun, 28 Aug 2005 18:13:58 -0700, voipcanada wrote:
          [color=blue]
          > no one answered this till now, i need to know the exact code to be
          > written ,, kind regards[/color]

          Look at your previous post and my response.

          --
          大红鹰娱乐平台采用顶级加密技术,确保用户数据与交易的安全无虞,让玩家能够放心畅玩。


          Comment

          • voipcanada

            #6
            Re: $alines = preg_split(&quo t;/=/", $lines);

            Dear Macbri

            it does work good but not when we want a file like this to be edited
            ,,,, please look at the file and if you can suggest some thing
            http://starkom.com/bill20050820_000000 .. thanks and regards

            Comment

            • Mladen Gogala

              #7
              Re: $alines = preg_split(&quo t;/=/", $lines);

              On Sun, 28 Aug 2005 18:24:19 -0700, voipcanada wrote:
              [color=blue]
              > Dear Macbri[/color]

              Plonk.

              --
              大红鹰娱乐平台采用顶级加密技术,确保用户数据与交易的安全无虞,让玩家能够放心畅玩。


              Comment

              • voipcanada

                #8
                Re: $alines = preg_split(&quo t;/=/", $lines);

                dear Mladen Gogala

                i tryed your suggestions but it does not work ,,,, i need to replace
                the in the file above ,, thanks

                Comment

                • macbri

                  #9
                  Re: $alines = preg_split(&quo t;/=/", $lines);


                  voipcanada Wrote:[color=blue]
                  > Dear Macbri
                  >
                  > it does work good but not when we want a file like this to be edited
                  > ,,,, please look at the file and if you can suggest some thing
                  > http://starkom.com/bill20050820_000000 .. thanks and regards[/color]
                  Why not split each line with preg_split() and then use the
                  preg_replace() as described....?


                  Code:
                  --------------------
                  foreach ($lines as $each) {
                  $line = preg_split("/,/", $each);
                  $line = preg_replace ... (etc.)
                  }
                  --------------------


                  --
                  macbri
                  ------------------------------------------------------------------------
                  macbri's Profile: http://www.macosx.com/forums/member.php?userid=34415
                  View this thread: http://www.macosx.com/forums/showthread.php?t=242019
                  macosx.com - The Answer to Mac Support - http://www.macosx.com

                  Comment

                  • kerul4u

                    #10
                    Re: $alines = preg_split(&quo t;/=/", $lines);

                    Instead of using preg_split why not trying to reading and writing file

                    try out this

                    //Suppose Your file is bill20050820_00 0000.txt
                    $file = "bill20050820_0 00000.txt";
                    $fp = fopen($file,'r' );
                    $string = fread($fp, filesize($file) );
                    fclose($fp);
                    //Array of special charecters you want to replace
                    $special =
                    array('DST-NUMBER-IN=','DST-NUMBER-OUT=','DST-NUMBER-BILL=');
                    $replacements = "";

                    $string = str_replace($sp ecial,$replacem ents,$string);
                    //Write back to file
                    $fp = fopen($file,'w' );
                    fwrite($fp, $string);
                    fclose($fp);

                    +++++++++++++++ ++
                    if you find it useful plz notify me
                    KERUL
                    [ProDesignZ]

                    Comment

                    • voipcanada

                      #11
                      Re: $alines = preg_split(&quo t;/=/", $lines);

                      thanks to your so much ,, kind regards

                      Comment

                      • macbri

                        #12
                        Re: $alines = preg_split(&quo t;/=/", $lines);


                        kerul4u Wrote:[color=blue]
                        > Instead of using preg_split why not trying to reading and writing file
                        >
                        > --snip--
                        > //Array of special charecters you want to replace
                        > $special =
                        > array('DST-NUMBER-IN=','DST-NUMBER-OUT=','DST-NUMBER-BILL=');
                        > $replacements = "";
                        >
                        > $string = str_replace($sp ecial,$replacem ents,$string);
                        > --snip--[/color]

                        Not a bad idea, but if you look at the contents of the OP's actual file
                        there's a lot of other stuff in there. Especially dates, IP addresses
                        etc. Your array of special characters might become a bit unwieldy:
                        [color=blue]
                        >
                        > Sat Aug 20 10:59:31 2005, HOST=xxx.xxx.xx x.xxx,
                        > DST-NUMBER-IN=003351xxxxxx xx, DST-NUMBER-OUT=98751#33512 xxxxxxxx,
                        > DST-NUMBER-BILL=003351xxxx xxxx, SRC-IP=xxx.xxx.xxx. xxx:1456,
                        > DST-IP=xxx.xxx.xxx. xxx.246:1720, SRC-USER=125, DST-USER=easylink,
                        > SRC-NAME=U11, DST-NAME=easylink, DIALPEER-NAME=R30,
                        > INITIAL-INCOMING-LOCAL-ADDRESS=xxx.xxx .xxx.xxx,
                        > SELECTED-INCOMING-LOCAL-ADDRESS=xxx.xxx .xxx.xxx,
                        > OUTGOING-LOCAL-ADDRESS=xxx.xxx .xxx.xxx, RECORD-ID=1124534625-0,
                        > ELAPSED-TIME=0, SETUP-TIME=10:59:31.0 00 GMT Sat Aug 20 2005,
                        > CONNECT-TIME=10:59:31.0 00 GMT Sat Aug 20 2005,
                        > DISCONNECT-TIME=10:59:31.0 00 GMT Sat Aug 20 2005,
                        > DISCONNECT-CODE-LOCAL=2, DISCONNECT-CODE-Q931=1, SRC-BYTES-IN=604,
                        > DST-BYTES-IN=95, SRC-BYTES-OUT=0, DST-BYTES-OUT=630, QOS=0,
                        > SRC-CODEC=g729B g729 g729AwB g729A g7231 gsmFR g711U64k g711A64k ,
                        > CALLID=0221d499 c177861a56343xx xxxxxxxxxx,
                        > CONFID=0221d499 c17bc32456343xx xxxxxxxx, PROXY-MODE=1, ROUTE-RETRIES=1[/color]

                        But, based on the OP's latest reply, I guess he/she has a solution that
                        works, so the point is moot now anyway :)


                        --
                        macbri
                        ------------------------------------------------------------------------
                        macbri's Profile: http://www.macosx.com/forums/member.php?userid=34415
                        View this thread: http://www.macosx.com/forums/showthread.php?t=242019
                        macosx.com - The Answer to Mac Support - http://www.macosx.com

                        Comment

                        • voipcanada

                          #13
                          Re: $alines = preg_split(&quo t;/=/", $lines);

                          hi all the colums were added ,,,, fi there is any other suggestions ,,
                          let me know

                          $fp = fopen($fname,'r ');
                          $string = fread($fp, filesize($fname ));
                          fclose($fp);
                          //Array of special charecters you want to replace
                          $special =
                          array('DST-NUMBER-IN=','DST-NUMBER-OUT=','DST-NUMBER-BILL=','HOST=', 'SRC-IP=','DST-IP=','SRC-USER=','DST-USER=','SRC-NAME=','DST-NAME=','DIALPEE R-NAME=','INITIAL-INCOMING-LOCAL-ADDRESS=','SELE CTED-INCOMING-LOCAL-ADDRESS=','OUTG OING-LOCAL-ADDRESS=','RECO RD-ID=','ELAPSED-TIME=','SETUP-TIME=','DISCONN ECT-TIME=','DISCONN ECT-CODE-LOCAL=','DISCON NECT-CODE-Q931=');
                          $replacements = "";

                          $string = str_replace($sp ecial,$replacem ents,$string);
                          //Write back to file
                          $fp = fopen($fname,'w ');
                          fwrite($fp, $string);
                          fclose($fp);

                          Comment

                          • kerul4u

                            #14
                            Re: $alines = preg_split(&quo t;/=/", $lines);

                            hi,

                            if it works for you its the better way..if having any problem state it
                            here so we can give other suggetion.

                            KERUL
                            [ProDesignZ]

                            Comment

                            • kerul4u

                              #15
                              Re: $alines = preg_split(&quo t;/=/", $lines);

                              hey,

                              I've look at your previous posts.
                              You are posting the same problem with diff. presentation.
                              Wat it mean man? What you want exactly?
                              Do you need someone to write code for you? Cause after looking your
                              previous post I can guess u don't know PHP.
                              If so plz don't waste your and others time. Just directly post wat you
                              want and wat you need.

                              KERUL
                              [ProDesignZ]

                              Comment

                              Working...