Announcement

Collapse
No announcement yet.

$variable =~ s/ /\_/g;

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • $variable =~ s/ /\_/g;

    Why doesn't this for in PHP???

  • #2
    What is it supposed to do?
    maybe there is another way of doing it.
    Visual Basic, HTML, PHP, SQL, ASP, JavaScript, C++, Perl

    PHP 4.0.6
    MySQL 3.23.39
    Windows 2000

    Comment


    • #3
      Dumb me, I forgot the quotes.
      I have another question tho.
      Is there an -e equivilent in PHP?

      Comment


      • #4
        DW, that is a Perl code that searches threw the variable for an "_" in this case and changes it to a space I think.

        Comment


        • #5
          There is a function in PHP called str_replace...

          Code:
          str_replace($what_to_find, $what_to_replace_it_with, $the_main_text);
          
          Ex:
          
          $mystr = "Hello Jalit This is from Bob";
          //my name isn't bob.. 
          $mystr = str_replace("Bob", "Dennis", $mystr);
          I think thats a little more coherint than that perl-like function....

          I was trying to learn Perl a while ago... I even have a few good books on it. but Since i heard of PHP, I stopped.. because compared to PHP, Perl sucks.......

          Visual Basic, HTML, PHP, SQL, ASP, JavaScript, C++, Perl

          PHP 4.0.6
          MySQL 3.23.39
          Windows 2000

          Comment


          • #6
            Looks like sed to me.. (yoonix command)

            Comment


            • #7
              I need more help!!!
              is there something like this in php???
              -----
              @filedata = <FILE>;
              -----

              Comment


              • #8
                file("/path/to/file/file.txt");

                Comment


                • #9
                  So it would be this:
                  -----
                  @filedata = file("$filetorequire");
                  -----
                  Right?????

                  Comment


                  • #10
                    no, in PHP
                    you don't have to differentiate an array with the @ sign

                    it would be:
                    $filedata = file("$filetorequire");

                    See:
                    http://www.php.net/manual/function.file.php





                    [Edited by Anscoop on 10-01-2000 at 09:19 PM]

                    Comment

                    widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
                    Working...
                    X