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

need help

Expand Messages
  • mainul
    how do I remove the last comma in the string? here is the link http://pastebin.com/2gKUaE70 Please help me
    Message 1 of 30 , Apr 4 12:16 AM
    View Source
    • 0 Attachment
      how do I remove the last comma in the string?
      here is the link http://pastebin.com/2gKUaE70

      Please help me
    • mainul
      http://pastebin.com/2gKUaE70 how do I remove the last comma in the string?
      Message 2 of 30 , Apr 4 12:17 AM
      View Source
      • 0 Attachment
        http://pastebin.com/2gKUaE70

        how do I remove the last comma in the string?
      • shiplu
        Here you can use implode function. echo Array to string separated by comma ; echo implode( , , $cities); --
        Message 3 of 30 , Apr 4 1:27 AM
        View Source
        • 0 Attachment

          Here you can use implode function.

          echo "<h2>Array to string separated by comma</h2><br>";
          echo implode(', ', $cities);
          --
          Shiplu.Mokadd.im
          ImgSign.com | A dynamic signature machine

          Innovation distinguishes between follower and leader
        • M.Mukaddim Islam Tanim
          use this: rtrim($string, , ) would cut trailing commas.   -- M Mukaddim Islam Tanim ________________________________ From: mainul To:
          Message 4 of 30 , Apr 4 1:47 AM
          View Source
          • 0 Attachment
            use this: rtrim($string, ",") would cut trailing commas.
             
            -- M Mukaddim Islam Tanim

            From: mainul <myrulz007@...>
            To: phpexperts@yahoogroups.com
            Sent: Thursday, April 4, 2013 1:17 PM
            Subject: [phpXperts] need help

             
            http://pastebin.com/2gKUaE70

            how do I remove the last comma in the string?



          • M.Mukaddim Islam Tanim
            Your code: 1. $cities = array( Tokyo , Mexico City , New York City , Mumbai , Seoul , Shanghai , Lagos , Buenos Aires , Cairo , London ); 2.      
            Message 5 of 30 , Apr 4 1:53 AM
            View Source
            • 0 Attachment
              Your code:
              1. $cities = array('Tokyo', 'Mexico City', 'New York City', 'Mumbai', 'Seoul', 'Shanghai', 'Lagos', 'Buenos Aires', 'Cairo', 'London');
              2.                
              3.                 echo "<h2>Array to string separated by comma</h2><br>";
              4.                 foreach ($cities as $result) { 
              5.                     $string = $result. ', ';
              6.                         echo $string;
              7.                 }

              Use this code instead of previous one: 

              $cities = array('Tokyo', 'Mexico City', 'New York City', 'Mumbai', 'Seoul', 'Shanghai', 'Lagos', 'Buenos Aires', 'Cairo', 'London');
              $string = null;
              echo "<h2>Array to string separated by comma</h2><br>";
              foreach ($cities as $result) {
                 $string .= $result. ', ';
              }
              echo rtrim($string, ",");



              From: M.Mukaddim Islam Tanim <tanim_mmi@...>
              To: "phpexperts@yahoogroups.com" <phpexperts@yahoogroups.com>
              Sent: Thursday, April 4, 2013 2:47 PM
              Subject: Re: [phpXperts] need help

              use this: rtrim($string, ",") would cut trailing commas.
               
              -- M Mukaddim Islam Tanim

              From: mainul <myrulz007@...>
              To: phpexperts@yahoogroups.com
              Sent: Thursday, April 4, 2013 1:17 PM
              Subject: [phpXperts] need help

               
              http://pastebin.com/2gKUaE70

              how do I remove the last comma in the string?





            • foysal foysal
              Mainul vai You can use the below solution
              Message 6 of 30 , Apr 4 5:19 AM
              View Source
              • 0 Attachment
                Mainul vai

                You can use the below solution

                <?php

                $cities = array('Tokyo', 'Mexico City', 'New York City', 'Mumbai', 'Seoul', 'Shanghai', 'Lagos', 'Buenos Aires', 'Cairo', 'London');              

                echo "<h2>Array to string separated by comma</h2><br>"

                foreach ($cities as $result)
                  if($result == end($cities))
                  {
                      echo $result;
                  }
                  else
                  {
                     echo $result.',';
                  }  

                }

                ?>


                Thanks

                Foysal


                On Thu, Apr 4, 2013 at 2:27 PM, shiplu <shiplu.net@...> wrote:
                 


                Here you can use implode function.

                echo "<h2>Array to string separated by comma</h2><br>";
                echo implode(', ', $cities);
                --
                Shiplu.Mokadd.im
                ImgSign.com | A dynamic signature machine

                Innovation distinguishes between follower and leader


              • foysal foysal
                Mainul vai, You can see the below code. http://pastebin.com/4cB5hGui Thanks Foysal On Thu, Apr 4, 2013 at 2:53 PM, M.Mukaddim Islam Tanim
                Message 7 of 30 , Apr 15 8:38 PM
                View Source
                • 0 Attachment
                  Mainul vai,

                  You can see the below code.

                  http://pastebin.com/4cB5hGui

                  Thanks

                  Foysal


                  On Thu, Apr 4, 2013 at 2:53 PM, M.Mukaddim Islam Tanim <tanim_mmi@...> wrote:
                   

                  Your code:
                  1. $cities = array('Tokyo', 'Mexico City', 'New York City', 'Mumbai', 'Seoul', 'Shanghai', 'Lagos', 'Buenos Aires', 'Cairo', 'London');
                  2.                
                  3.                 echo "<h2>Array to string separated by comma</h2><br>";
                  4.                 foreach ($cities as $result) { 
                  5.                     $string = $result. ', ';
                  6.                         echo $string;
                  7.                 }

                  Use this code instead of previous one: 

                  $cities = array('Tokyo', 'Mexico City', 'New York City', 'Mumbai', 'Seoul', 'Shanghai', 'Lagos', 'Buenos Aires', 'Cairo', 'London');
                  $string = null;
                  echo "<h2>Array to string separated by comma</h2><br>";
                  foreach ($cities as $result) {
                     $string .= $result. ', ';
                  }
                  echo rtrim($string, ",");



                  From: M.Mukaddim Islam Tanim <tanim_mmi@...>
                  To: "phpexperts@yahoogroups.com" <phpexperts@yahoogroups.com>
                  Sent: Thursday, April 4, 2013 2:47 PM
                  Subject: Re: [phpXperts] need help

                  use this: rtrim($string, ",") would cut trailing commas.
                   
                  -- M Mukaddim Islam Tanim

                  From: mainul <myrulz007@...>
                  To: phpexperts@yahoogroups.com
                  Sent: Thursday, April 4, 2013 1:17 PM
                  Subject: [phpXperts] need help

                   
                  http://pastebin.com/2gKUaE70

                  how do I remove the last comma in the string?






                • Arifur Rahman
                  hello, there is way you can sub string 1 character from last ... -- Muhammad Arifur Rahman Senior Software Engineer CEO,Smart Data Soft
                  Message 8 of 30 , Apr 15 9:37 PM
                  View Source
                  • 0 Attachment
                    hello, there is way you can sub string 1 character from last


                    On Thu, Apr 4, 2013 at 1:16 PM, mainul <myrulz007@...> wrote:
                     

                    how do I remove the last comma in the string?
                    here is the link http://pastebin.com/2gKUaE70

                    Please help me




                    --
                    Muhammad Arifur Rahman
                    Senior Software Engineer
                    CEO,Smart Data Soft
                  • Saiful Islam
                    Hi Dear. Please try in this way substr_replace($string, , -1) Regards, -- Saiful Islam Web Application Developer http://www.saifulbd.com
                    Message 9 of 30 , Apr 15 11:44 PM
                    View Source
                    • 0 Attachment
                      Hi Dear.
                      Please try in this way
                      substr_replace($string, "", -1)



                      Regards,

                      --
                      Saiful Islam
                      Web Application Developer
                      http://www.saifulbd.com


                      On Tue, Apr 16, 2013 at 12:37 PM, Arifur Rahman <arifur.aiub@...> wrote:
                       

                      hello, there is way you can sub string 1 character from last


                      On Thu, Apr 4, 2013 at 1:16 PM, mainul <myrulz007@...> wrote:
                       

                      how do I remove the last comma in the string?
                      here is the link http://pastebin.com/2gKUaE70

                      Please help me




                      --
                      Muhammad Arifur Rahman
                      Senior Software Engineer
                      CEO,Smart Data Soft


                    • Saleha Latif
                      Hi, Here i want to mentioned that sometimes this below code wont work: $mystring = substr( a,b,c,d, , 0,-1);  because it has space at the end of the string
                      Message 10 of 30 , Apr 16 7:26 AM
                      View Source
                      • 0 Attachment
                        Hi,

                        Here i want to mentioned that sometimes this below code wont work:
                        $mystring = substr("a,b,c,d, ", 0,-1); 
                        because it has space at the end of the string so instead, use this one:
                        $mystring = substr(trim("a,b,c,d, "), 0,-1); 

                        hope help for anyone
                        Regards
                        Saleha A.Latif


                        From: mainul <myrulz007@...>
                        To: phpexperts@yahoogroups.com
                        Sent: Thursday, April 4, 2013 12:16 PM
                        Subject: [phpXperts] need help

                         
                        how do I remove the last comma in the string?
                        here is the link http://pastebin.com/2gKUaE70

                        Please help me



                      • moinul islam
                        Dear Group, I want to develop network monitoring tool in PHP.i have serached in google.but didn t get enough resource. i want to have the following options in
                        Message 11 of 30 , Apr 17 12:48 AM
                        View Source
                        • 0 Attachment
                          Dear Group,
                          I want to develop network monitoring tool in PHP.i have serached in google.but didn't get enough resource.
                          i want to have the following options in tht php based network monitoring tool:
                          1.Ping reply from router.
                          2.Bandwidth usage in LAN.
                          is there anybody can plz help me??


                          From: Saiful Islam <abssaiful@...>
                          To: phpexperts <phpexperts@yahoogroups.com>
                          Sent: Tuesday, 16 April 2013, 12:44
                          Subject: Re: [phpXperts] need help

                           
                          Hi Dear.
                          Please try in this way
                          substr_replace($string, "", -1)



                          Regards,

                          --
                          Saiful Islam
                          Web Application Developer
                          http://www.saifulbd.com


                          On Tue, Apr 16, 2013 at 12:37 PM, Arifur Rahman <arifur.aiub@...> wrote:
                           
                          hello, there is way you can sub string 1 character from last


                          On Thu, Apr 4, 2013 at 1:16 PM, mainul <myrulz007@...> wrote:
                           
                          how do I remove the last comma in the string?
                          here is the link http://pastebin.com/2gKUaE70

                          Please help me




                          --
                          Muhammad Arifur Rahman
                          Senior Software Engineer
                          CEO,Smart Data Soft



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