Loading ...
Sorry, an error occurred while loading the content.
 

Re: [phpXperts] Need Help regrading interchange two value

Expand Messages
  • Arafat Rahman
    Hi Sumon, To swap two string variable you can use *xor*. Here is an example. $a = Arafat ; $b = Rahman ; echo($a . - . $b . ); $a = $a ^ $b; $b =
    Message 1 of 13 , Sep 23 7:31 PM
      Hi Sumon,
      To swap two string variable you can use xor. Here is an example.

      $a = 'Arafat';
      $b = 'Rahman';

      echo($a . ' - ' . $b . '<br />');

      $a = $a ^ $b;
      $b = $a ^ $b;
      $a = $a ^ $b;

      echo($a . ' - ' . $b . '<br />');


      Arafat Rahman
      http://arafatbd.net
    • ziaul haq
      Hi Its called value swapping. You can do it easily with list() method. Please take a look below :
      Message 2 of 13 , Sep 23 10:52 PM
        Hi

        Its called value swapping. You can do it easily with list() method.

        Please take a look below :

        <?php
            $a  = 'abc';
            $x = 'xyz';
           
            list($a,$x) = array($x,$a);
           
            echo $a.'--'.$x;
        ?>

        It will work nicely.

        Thanks
        Zia

        ----- Original Message ----
        From: S.M. Abu Sayeed <hi_emelle@...>
        To: phpexpart <phpexperts@yahoogroups.com>
        Sent: Wednesday, September 24, 2008 7:57:46 AM
        Subject: [phpXperts] Need Help regrading interchange two value

        Hi all,
        I m in problem with a simple problem regrading interchange two value in the two variable without using any third variable.
        I can make it with any type of number and the char variable but when it's string variable on that time I can't solve the problem.
        Its some thing like...

        a = pqr
        b = xyz

        After interchange the result should be
        a = xyz
        b = pqr

        But here we should not use any variable expect a & b.

        Please help me abut the problem.


         

        Regards,
        S.M.Sumon.



      • S.M. Abu Sayeed
        Hi Zia, Thanks for ur nice solution but U have user array function and list method. U should not use any function. Please try again without any function.
        Message 3 of 13 , Sep 24 9:14 PM
          Hi Zia,
          Thanks for ur nice solution but U have user array function and list method.
          U should not use any function.
          Please try again without any function.

           

          Regards,
          S.M.Sumon.


          ----- Original Message ----
          From: ziaul haq <zia_112@...>
          To: phpexperts@yahoogroups.com
          Sent: Wednesday, September 24, 2008 11:52:24 AM
          Subject: Re: [phpXperts] Need Help regrading interchange two value

          Hi

          Its called value swapping. You can do it easily with list() method.

          Please take a look below :

          <?php
              $a  = 'abc';
              $x = 'xyz';
             
              list($a,$x) = array($x,$a) ;
             
              echo $a.'--'.$x;
          ?>

          It will work nicely.

          Thanks
          Zia

          ----- Original Message ----
          From: S.M. Abu Sayeed <hi_emelle@yahoo. com>
          To: phpexpart <phpexperts@yahoogro ups.com>
          Sent: Wednesday, September 24, 2008 7:57:46 AM
          Subject: [phpXperts] Need Help regrading interchange two value

          Hi all,
          I m in problem with a simple problem regrading interchange two value in the two variable without using any third variable.
          I can make it with any type of number and the char variable but when it's string variable on that time I can't solve the problem.
          Its some thing like...

          a = pqr
          b = xyz

          After interchange the result should be
          a = xyz
          b = pqr

          But here we should not use any variable expect a & b.

          Please help me abut the problem.


           

          Regards,
          S.M.Sumon.




        • S.M. Abu Sayeed
          Hi Arafat, Thanks for ur nice solution. But did u check ur code with $a = Arafatabcdefgh and $b = Rahman . Then u can swap only first 6 char not in the full
          Message 4 of 13 , Sep 24 9:19 PM
            Hi Arafat,
            Thanks for ur nice solution.
            But did u check ur code with $a = 'Arafatabcdefgh' and $b ='Rahman'.
            Then u can swap only first 6 char not in the full of $a with $b.
            I think the xor  is not the right solution.
            U can not do this using xor.
             

            Regards,
            S.M.Sumon.


            ----- Original Message ----
            From: Arafat Rahman <opurahman@...>
            To: phpexperts@yahoogroups.com
            Sent: Wednesday, September 24, 2008 8:31:18 AM
            Subject: Re: [phpXperts] Need Help regrading interchange two value

            Hi Sumon,
            To swap two string variable you can use xor. Here is an example.

            $a = 'Arafat';
            $b = 'Rahman';

            echo($a . ' - ' . $b . '<br />');

            $a = $a ^ $b;
            $b = $a ^ $b;
            $a = $a ^ $b;

            echo($a . ' - ' . $b . '<br />');


            Arafat Rahman
            http://arafatbd. net

          • A.N.M. Saiful Islam
            Here is another Solution: $a = aaa ; $b = bbbbb ; $a = $a . $b; $b = str_replace( $b, , $a ); $a = str_replace( $b, , $a ); S.M. Abu Sayeed
            Message 5 of 13 , Sep 25 12:30 AM
              Here is another Solution:
               
              $a = "aaa";
              $b = "bbbbb";
               
              $a = $a . $b;
              $b = str_replace( $b, '', $a );
              $a = str_replace( $b, '', $a );
               
               

              "S.M. Abu Sayeed" <hi_emelle@...> wrote:
              Hi Arafat,
              Thanks for ur nice solution.
              But did u check ur code with $a = 'Arafatabcdefgh' and $b ='Rahman'.
              Then u can swap only first 6 char not in the full of $a with $b.
              I think the xor  is not the right solution.
              U can not do this using xor.
               

              Regards,
              S.M.Sumon.


              ----- Original Message ----
              From: Arafat Rahman <opurahman@gmail. com>
              To: phpexperts@yahoogro ups.com
              Sent: Wednesday, September 24, 2008 8:31:18 AM
              Subject: Re: [phpXperts] Need Help regrading interchange two value

              Hi Sumon,
              To swap two string variable you can use xor. Here is an example.

              $a = 'Arafat';
              $b = 'Rahman';

              echo($a . ' - ' . $b . '<br />');

              $a = $a ^ $b;
              $b = $a ^ $b;
              $a = $a ^ $b;

              echo($a . ' - ' . $b . '<br />');


              Arafat Rahman
              http://arafatbd. net






              $@!ful

              email@...

              http://anm-saiful.info


              Connect with friends all over the world. Get Yahoo! India Messenger.

            • Md. Bayezid Al-Arabi
              If a string is substring of another then these solutions will give you the wrong answer. The proper solution may be this: $a = aaa ; $b = bbbbbaaa ; echo($a
              Message 6 of 13 , Sep 25 1:55 AM
                If a string is substring of another then these
                solutions will give you the wrong answer.

                The proper solution may be this:

                $a = "aaa";

                $b = "bbbbbaaa";

                echo($a . ' - ' . $b . '<br />');

                $a = $a . $b;
                $b=substr($a,0,strlen($a)-strlen($b));
                $a=substr($a,strlen($b),strlen($a));

                echo($a . ' - ' . $b . '<br />');



                Eid Mubarak and Happy Ramadan





                --- "A.N.M. Saiful Islam" <anm.saiful@...>
                wrote:

                > Here is another Solution:
                >
                > $a = "aaa";
                > $b = "bbbbb";
                >
                > $a = $a . $b;
                > $b = str_replace( $b, '', $a );
                > $a = str_replace( $b, '', $a );
                >
                >
                >
                > "S.M. Abu Sayeed" <hi_emelle@...> wrote:
                > Hi Arafat,
                > Thanks for ur nice solution.
                > But did u check ur code with $a = 'Arafatabcdefgh'
                > and $b ='Rahman'.
                > Then u can swap only first 6 char not in the full of
                > $a with $b.
                > I think the xor is not the right solution.
                > U can not do this using xor.
                >
                >
                > Regards,
                > S.M.Sumon.
                >
                >
                > ----- Original Message ----
                > From: Arafat Rahman <opurahman@...>
                > To: phpexperts@yahoogroups.com
                > Sent: Wednesday, September 24, 2008 8:31:18 AM
                > Subject: Re: [phpXperts] Need Help regrading
                > interchange two value
                >
                >
                > Hi Sumon,
                > To swap two string variable you can use xor. Here is
                > an example.
                >
                > $a = 'Arafat';
                > $b = 'Rahman';
                >
                > echo($a . ' - ' . $b . '<br />');
                >
                > $a = $a ^ $b;
                > $b = $a ^ $b;
                > $a = $a ^ $b;
                >
                > echo($a . ' - ' . $b . '<br />');
                >
                >
                > Arafat Rahman
                > http://arafatbd. net
                >
                >
                >
                >
                >
                >
                >
                >
                >
                >
                >
                >
                > ---------------------------------
                >
                > $@!ful
                >
                > email@...
                >
                > http://anm-saiful.info
                >
                > ---------------------------------
                > Connect with friends all over the world. Get
                > Yahoo! India Messenger.


                Best Regards
                _________________________
                Md. Bayezid Al-Arabi
                Software Engineer, ICT
                Institute of Water Modelling
                House # 496, Road # 32
                New DOHS, Mohakhali, Dhaka, Bangladesh
                Web: www.iwmbd.org
                Email: baa@...
                Phone:8822105-6 Ext 117
              • Tasim Php
                y dont u try by taking a temp variable. follow below codes: $a = you ; $b = me ; $temp; echo $a . = . $b ; echo ; $temp = $a; $a = $b; $b=$temp;
                Message 7 of 13 , Sep 25 2:49 AM
                  y dont u try by taking a temp variable. follow below codes:

                  $a = "you";
                  $b = "me";
                  $temp;
                  echo $a ." = ". $b ;
                  echo "<br />";

                  $temp = $a;
                  $a = $b;
                  $b=$temp;
                  echo $a ." = ". $b ;

                  values are swapped

                  Tasim Khan
                  India

                  ----- Original Message ----
                  From: A.N.M. Saiful Islam <anm.saiful@...>
                  To: phpexperts@yahoogroups.com
                  Sent: Thursday, September 25, 2008 1:00:35 PM
                  Subject: Re: [phpXperts] Need Help regrading interchange two value

                  Here is another Solution:
                   
                  $a = "aaa";
                  $b = "bbbbb";
                   
                  $a = $a . $b;
                  $b = str_replace( $b, '', $a );
                  $a = str_replace( $b, '', $a );
                   
                   

                  "S.M. Abu Sayeed" <hi_emelle@yahoo. com> wrote:
                  Hi Arafat,
                  Thanks for ur nice solution.
                  But did u check ur code with $a = 'Arafatabcdefgh' and $b ='Rahman'.
                  Then u can swap only first 6 char not in the full of $a with $b.
                  I think the xor  is not the right solution.
                  U can not do this using xor.
                   

                  Regards,
                  S.M.Sumon.


                  ----- Original Message ----
                  From: Arafat Rahman <opurahman@gmail. com>
                  To: phpexperts@yahoogro ups.com
                  Sent: Wednesday, September 24, 2008 8:31:18 AM
                  Subject: Re: [phpXperts] Need Help regrading interchange two value

                  Hi Sumon,
                  To swap two string variable you can use xor. Here is an example.

                  $a = 'Arafat';
                  $b = 'Rahman';

                  echo($a . ' - ' . $b . '<br />');

                  $a = $a ^ $b;
                  $b = $a ^ $b;
                  $a = $a ^ $b;

                  echo($a . ' - ' . $b . '<br />');


                  Arafat Rahman
                  http://arafatbd. net






                  $@!ful

                  email@anm-saiful. info

                  http://anm-saiful. info


                  Connect with friends all over the world. Get Yahoo! India Messenger.

                • S.M. Abu Sayeed
                  Hi, Hope doing good.I think U have miss my first mail. Please read my first mail. There I have mention u can t user any third variable, any function, any built
                  Message 8 of 13 , Sep 25 6:38 PM
                    Hi,
                        Hope doing good.I think U have miss my first mail.
                        Please read my first mail. There I have mention u can't
                       user any third variable, any function, any built in function.
                       Have a nice time.
                     

                    Regards,
                    S.M.Sumon.


                    ----- Original Message ----
                    From: Tasim Php <tasimphp@...>
                    To: phpexperts@yahoogroups.com
                    Sent: Thursday, September 25, 2008 3:49:03 PM
                    Subject: Re: [phpXperts] Need Help regrading interchange two value

                    y dont u try by taking a temp variable. follow below codes:

                    $a = "you";
                    $b = "me";
                    $temp;
                    echo $a ." = ". $b ;
                    echo "<br />";

                    $temp = $a;
                    $a = $b;
                    $b=$temp;
                    echo $a ." = ". $b ;

                    values are swapped

                    Tasim Khan
                    India

                    ----- Original Message ----
                    From: A.N.M. Saiful Islam <anm.saiful@yahoo. com>
                    To: phpexperts@yahoogro ups.com
                    Sent: Thursday, September 25, 2008 1:00:35 PM
                    Subject: Re: [phpXperts] Need Help regrading interchange two value

                    Here is another Solution:
                     
                    $a = "aaa";
                    $b = "bbbbb";
                     
                    $a = $a . $b;
                    $b = str_replace( $b, '', $a );
                    $a = str_replace( $b, '', $a );
                     
                     

                    "S.M. Abu Sayeed" <hi_emelle@yahoo. com> wrote:
                    Hi Arafat,
                    Thanks for ur nice solution.
                    But did u check ur code with $a = 'Arafatabcdefgh' and $b ='Rahman'.
                    Then u can swap only first 6 char not in the full of $a with $b.
                    I think the xor  is not the right solution.
                    U can not do this using xor.
                     

                    Regards,
                    S.M.Sumon.


                    ----- Original Message ----
                    From: Arafat Rahman <opurahman@gmail. com>
                    To: phpexperts@yahoogro ups.com
                    Sent: Wednesday, September 24, 2008 8:31:18 AM
                    Subject: Re: [phpXperts] Need Help regrading interchange two value

                    Hi Sumon,
                    To swap two string variable you can use xor. Here is an example.

                    $a = 'Arafat';
                    $b = 'Rahman';

                    echo($a . ' - ' . $b . '<br />');

                    $a = $a ^ $b;
                    $b = $a ^ $b;
                    $a = $a ^ $b;

                    echo($a . ' - ' . $b . '<br />');


                    Arafat Rahman
                    http://arafatbd. net






                    $@!ful

                    email@anm-saiful. info

                    http://anm-saiful. info


                    Connect with friends all over the world. Get Yahoo! India Messenger.


                  • S.M. Abu Sayeed
                    Hi, Sorry dear, I can t accept ur code coz u have user some string built in function such as substr,strlen. some one is using array and built in php function.
                    Message 9 of 13 , Sep 25 6:42 PM
                      Hi,
                      Sorry dear, I can't accept ur code coz u have user some string built in function such as
                      substr,strlen. some one is using array and built in php function.

                      I am going to asked again same question...

                      I need to interchange two char value between two variable without any temp variable,
                      any function,any built in php function......etc.

                      Hope I will get help now with clear explanation.

                      Have a nice time.
                       

                      Regards,
                      S.M.Sumon.


                      ----- Original Message ----
                      From: Md. Bayezid Al-Arabi <sabuz_cse@...>
                      To: phpexperts@yahoogroups.com
                      Sent: Thursday, September 25, 2008 2:55:38 PM
                      Subject: Re: [phpXperts] Need Help regrading interchange two value

                      If a string is substring of another then these
                      solutions will give you the wrong answer.

                      The proper solution may be this:

                      $a = "aaa";

                      $b = "bbbbbaaa";

                      echo($a . ' - ' . $b . '<br />');

                      $a = $a . $b;
                      $b=substr($a, 0,strlen( $a)-strlen( $b));
                      $a=substr($a, strlen($b) ,strlen($ a));

                      echo($a . ' - ' . $b . '<br />');

                      Eid Mubarak and Happy Ramadan

                      --- "A.N.M. Saiful Islam" <anm.saiful@yahoo. com>
                      wrote:

                      > Here is another Solution:
                      >
                      > $a = "aaa";
                      > $b = "bbbbb";
                      >
                      > $a = $a . $b;
                      > $b = str_replace( $b, '', $a );
                      > $a = str_replace( $b, '', $a );
                      >
                      >
                      >
                      > "S.M. Abu Sayeed" <hi_emelle@yahoo. com> wrote:
                      > Hi Arafat,
                      > Thanks for ur nice solution.
                      > But did u check ur code with $a = 'Arafatabcdefgh'
                      > and $b ='Rahman'.
                      > Then u can swap only first 6 char not in the full of
                      > $a with $b.
                      > I think the xor is not the right solution.
                      > U can not do this using xor.
                      >
                      >
                      > Regards,
                      > S.M.Sumon.
                      >
                      >
                      > ----- Original Message ----
                      > From: Arafat Rahman <opurahman@gmail. com>
                      > To: phpexperts@yahoogro ups.com
                      > Sent: Wednesday, September 24, 2008 8:31:18 AM
                      > Subject: Re: [phpXperts] Need Help regrading
                      > interchange two value
                      >
                      >
                      > Hi Sumon,
                      > To swap two string variable you can use xor. Here is
                      > an example.
                      >
                      > $a = 'Arafat';
                      > $b = 'Rahman';
                      >
                      > echo($a . ' - ' . $b . '<br />');
                      >
                      > $a = $a ^ $b;
                      > $b = $a ^ $b;
                      > $a = $a ^ $b;
                      >
                      > echo($a . ' - ' . $b . '<br />');
                      >
                      >
                      > Arafat Rahman
                      > http://arafatbd. net
                      >
                      >
                      >
                      >
                      >
                      >
                      >
                      >
                      >
                      >
                      >
                      >
                      > ------------ --------- --------- ---
                      >
                      > $@!ful
                      >
                      > email@anm-saiful. info
                      >
                      > http://anm-saiful. info
                      >
                      > ------------ --------- --------- ---
                      > Connect with friends all over the world. Get
                      > Yahoo! India Messenger.

                      Best Regards
                      ____________ _________ ____
                      Md. Bayezid Al-Arabi
                      Software Engineer, ICT
                      Institute of Water Modelling
                      House # 496, Road # 32
                      New DOHS, Mohakhali, Dhaka, Bangladesh
                      Web: www.iwmbd.org
                      Email: baa@...
                      Phone:8822105- 6 Ext 117


                    • ziaul haq
                      Hi Sumon I think you also forgot your first mail. You never mention there about any function, any built in function . You just told about third variable not
                      Message 10 of 13 , Sep 25 9:32 PM
                        Hi Sumon

                        I think you also forgot your first mail.
                        You never mention there about 'any function, any built in function'.

                        You just told about third variable not function nor built in method.

                        Take a look below about your first mail:
                        '
                        Hi all,
                        I m in problem with a simple problem regrading interchange two value in the two variable without using any third variable.
                        I can make it with any type of number and the char variable but when it's string variable on that time I can't solve the problem.
                        '

                        I think you shouldn't forgot it.

                        Thsnks
                        Zia


                        ----- Original Message ----
                        From: S.M. Abu Sayeed <hi_emelle@...>
                        To: phpexperts@yahoogroups.com
                        Sent: Friday, September 26, 2008 7:38:35 AM
                        Subject: Re: [phpXperts] Need Help regrading interchange two value

                        Hi,
                            Hope doing good.I think U have miss my first mail.
                            Please read my first mail. There I have mention u can't
                           user any third variable, any function, any built in function.
                           Have a nice time.
                         

                        Regards,
                        S.M.Sumon.


                        ----- Original Message ----
                        From: Tasim Php <tasimphp@rocketmail .com>
                        To: phpexperts@yahoogro ups.com
                        Sent: Thursday, September 25, 2008 3:49:03 PM
                        Subject: Re: [phpXperts] Need Help regrading interchange two value

                        y dont u try by taking a temp variable. follow below codes:

                        $a = "you";
                        $b = "me";
                        $temp;
                        echo $a ." = ". $b ;
                        echo "<br />";

                        $temp = $a;
                        $a = $b;
                        $b=$temp;
                        echo $a ." = ". $b ;

                        values are swapped

                        Tasim Khan
                        India

                        ----- Original Message ----
                        From: A.N.M. Saiful Islam <anm.saiful@yahoo. com>
                        To: phpexperts@yahoogro ups.com
                        Sent: Thursday, September 25, 2008 1:00:35 PM
                        Subject: Re: [phpXperts] Need Help regrading interchange two value

                        Here is another Solution:
                         
                        $a = "aaa";
                        $b = "bbbbb";
                         
                        $a = $a . $b;
                        $b = str_replace( $b, '', $a );
                        $a = str_replace( $b, '', $a );
                         
                         

                        "S.M. Abu Sayeed" <hi_emelle@yahoo. com> wrote:
                        Hi Arafat,
                        Thanks for ur nice solution.
                        But did u check ur code with $a = 'Arafatabcdefgh' and $b ='Rahman'.
                        Then u can swap only first 6 char not in the full of $a with $b.
                        I think the xor  is not the right solution.
                        U can not do this using xor.
                         

                        Regards,
                        S.M.Sumon.


                        ----- Original Message ----
                        From: Arafat Rahman <opurahman@gmail. com>
                        To: phpexperts@yahoogro ups.com
                        Sent: Wednesday, September 24, 2008 8:31:18 AM
                        Subject: Re: [phpXperts] Need Help regrading interchange two value

                        Hi Sumon,
                        To swap two string variable you can use xor. Here is an example.

                        $a = 'Arafat';
                        $b = 'Rahman';

                        echo($a . ' - ' . $b . '<br />');

                        $a = $a ^ $b;
                        $b = $a ^ $b;
                        $a = $a ^ $b;

                        echo($a . ' - ' . $b . '<br />');


                        Arafat Rahman
                        http://arafatbd. net






                        $@!ful

                        email@anm-saiful. info

                        http://anm-saiful. info


                        Connect with friends all over the world. Get Yahoo! India Messenger.



                      • 9el
                        ... Dear Sumon, Its not clear why you wanna ask the question? What is the goal to it? Code optimization relies on the target usage of the code. If not worth
                        Message 11 of 13 , Sep 26 11:45 AM
                          >>Re: Need Help regrading interchange two value
                          >>>>
                          >>
                          >>Thu Sep 25, 2008 9:19 pm (PDT)
                          >>
                          >>Hi,
                          >>Sorry dear, I can't accept ur code coz u have user some string built in function such as
                          >>substr,strlen. some one is using array and built in php function.
                          >>
                          >>I am going to asked again same question...
                          >>
                          >>I need to interchange two char value between two variable without any temp variable,
                          >>any function,any built in php function......etc.
                          >>
                          >>Hope I will get help now with clear explanation.
                          >>
                          >>Have a nice time.
                          >>
                          >>Regards,
                          >>S.M.Sumon.

                          Dear Sumon,
                          Its not clear why you wanna ask the question? What is the goal to it?
                          Code optimization relies on the target usage of the code. If not worth
                          you shouldn't waste time on ez matters too much. Why do you forbid to
                          use built in function or array?
                          the list() and array method is one special advantage of PHP.
                          And what you had in conclusion? Did you answer the question yourself?

                          Regards

                          9el
                        • S.M. Abu Sayeed
                          hi, sorry dear... I forget that. Regards, S.M.Sumon. ... From: ziaul haq To: phpexperts@yahoogroups.com Sent: Friday, September 26, 2008
                          Message 12 of 13 , Sep 26 7:02 PM
                            hi,
                            sorry dear... I forget that.
                             

                            Regards,
                            S.M.Sumon.


                            ----- Original Message ----
                            From: ziaul haq <zia_112@...>
                            To: phpexperts@yahoogroups.com
                            Sent: Friday, September 26, 2008 10:32:08 AM
                            Subject: Re: [phpXperts] Need Help regrading interchange two value

                            Hi Sumon

                            I think you also forgot your first mail.
                            You never mention there about 'any function, any built in function'.

                            You just told about third variable not function nor built in method.

                            Take a look below about your first mail:
                            '
                            Hi all,
                            I m in problem with a simple problem regrading interchange two value in the two variable without using any third variable.
                            I can make it with any type of number and the char variable but when it's string variable on that time I can't solve the problem.
                            '

                            I think you shouldn't forgot it.

                            Thsnks
                            Zia


                            ----- Original Message ----
                            From: S.M. Abu Sayeed <hi_emelle@yahoo. com>
                            To: phpexperts@yahoogro ups.com
                            Sent: Friday, September 26, 2008 7:38:35 AM
                            Subject: Re: [phpXperts] Need Help regrading interchange two value

                            Hi,
                                Hope doing good.I think U have miss my first mail.
                                Please read my first mail. There I have mention u can't
                               user any third variable, any function, any built in function.
                               Have a nice time.
                             

                            Regards,
                            S.M.Sumon.


                            ----- Original Message ----
                            From: Tasim Php <tasimphp@rocketmail .com>
                            To: phpexperts@yahoogro ups.com
                            Sent: Thursday, September 25, 2008 3:49:03 PM
                            Subject: Re: [phpXperts] Need Help regrading interchange two value

                            y dont u try by taking a temp variable. follow below codes:

                            $a = "you";
                            $b = "me";
                            $temp;
                            echo $a ." = ". $b ;
                            echo "<br />";

                            $temp = $a;
                            $a = $b;
                            $b=$temp;
                            echo $a ." = ". $b ;

                            values are swapped

                            Tasim Khan
                            India

                            ----- Original Message ----
                            From: A.N.M. Saiful Islam <anm.saiful@yahoo. com>
                            To: phpexperts@yahoogro ups.com
                            Sent: Thursday, September 25, 2008 1:00:35 PM
                            Subject: Re: [phpXperts] Need Help regrading interchange two value

                            Here is another Solution:
                             
                            $a = "aaa";
                            $b = "bbbbb";
                             
                            $a = $a . $b;
                            $b = str_replace( $b, '', $a );
                            $a = str_replace( $b, '', $a );
                             
                             

                            "S.M. Abu Sayeed" <hi_emelle@yahoo. com> wrote:
                            Hi Arafat,
                            Thanks for ur nice solution.
                            But did u check ur code with $a = 'Arafatabcdefgh' and $b ='Rahman'.
                            Then u can swap only first 6 char not in the full of $a with $b.
                            I think the xor  is not the right solution.
                            U can not do this using xor.
                             

                            Regards,
                            S.M.Sumon.


                            ----- Original Message ----
                            From: Arafat Rahman <opurahman@gmail. com>
                            To: phpexperts@yahoogro ups.com
                            Sent: Wednesday, September 24, 2008 8:31:18 AM
                            Subject: Re: [phpXperts] Need Help regrading interchange two value

                            Hi Sumon,
                            To swap two string variable you can use xor. Here is an example.

                            $a = 'Arafat';
                            $b = 'Rahman';

                            echo($a . ' - ' . $b . '<br />');

                            $a = $a ^ $b;
                            $b = $a ^ $b;
                            $a = $a ^ $b;

                            echo($a . ' - ' . $b . '<br />');


                            Arafat Rahman
                            http://arafatbd. net






                            $@!ful

                            email@anm-saiful. info

                            http://anm-saiful. info


                            Connect with friends all over the world. Get Yahoo! India Messenger.




                          Your message has been successfully submitted and would be delivered to recipients shortly.