Could this be a PHP 4.3.6 "feature"?

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

    Could this be a PHP 4.3.6 "feature"?

    [PHP]
    echo "val = $val<P>";
    list($mySection , $myDisplay) = explode('|', $val);
    echo "mySection = $mySection and myDisplay = $myDisplay<P>";
    [/PHP]

    In using PHP 4.3.6 here are my results:

    val = image|Image Maintenance

    mySection = image and myDisplay = image
    I narrowed down the problem to this:

    [PHP]
    $blahArray = explode('|', $val);
    print_r($blahAr ray);
    $blahArray = split('|', $val);
    print_r($blahAr ray);
    [/PHP]

    Nothing prints out, the array $blahArray is never set, not even to an
    empty array. No error messages nor warnings result in this.

    Has anyone had any similar problems with PHP 4.3.6 or am I just the
    "lucky one"? If so, is this an undocumented bug in 4.3.6 (all I could
    find in www.php.net was that there was a negative limit to explode()
    ).

    I am unable myself to bounce the webserver as I do not have [yet] the
    privileges to do so to figure if that might be a requirement, so until
    the system admins have the time to do so (takes a minute *sigh*) I am
    trying to cover all possible angles to this rather wacky problem.

    Phil
  • rush

    #2
    Re: Could this be a PHP 4.3.6 &quot;feature&q uot;?

    "Phil Powell" <soazine@erols. com> wrote in message
    news:1cdca2a7.0 407260815.76308 879@posting.goo gle.com...[color=blue]
    > [PHP]
    > echo "val = $val<P>";
    > list($mySection , $myDisplay) = explode('|', $val);
    > echo "mySection = $mySection and myDisplay = $myDisplay<P>";
    > [/PHP][/color]

    hmm.. it would sound very strange that such bug exists. Just to be sure that
    there are no funny things in $val, could you try this snippet:

    [PHP]
    $val = "image|Imag e Maintenance";
    echo "val = $val<P>";
    list($mySection , $myDisplay) = explode('|', $val);
    echo "mySection = $mySection and myDisplay = $myDisplay<P>";
    [/PHP]

    rush
    --
    Get your very own domain easily. Fast and professional customer service.



    Comment

    • Jeffrey Silverman

      #3
      Re: Could this be a PHP 4.3.6 &quot;feature&q uot;?

      On Mon, 26 Jul 2004 09:15:54 -0700, Phil Powell wrote:
      [color=blue]
      > I narrowed down the problem to this:
      >
      > [PHP]
      > $blahArray = explode('|', $val);
      > print_r($blahAr ray);
      > $blahArray = split('|', $val);
      > print_r($blahAr ray);
      > [/PHP]
      >
      > Nothing prints out, the array $blahArray is never set, not even to an
      > empty array. No error messages nor warnings result in this.[/color]

      For me (although I must admit, I am running PHP 4.3.7), the OP code, when
      converted to "real" PHP code as follows, works for me:

      <!-- =============== ======= -->
      <pre>
      <?
      $val = "image|Imag e Maintenance";
      $blahArray = explode('|', $val);
      print_r($blahAr ray);
      $blahArray = split('|', $val);
      print_r($blahAr ray);
      ?>
      </pre>
      <!-- =============== ======= -->

      (<pre> tags just there to help with formatting the output)

      But I do get an error:

      Warning: split(): REG_EMPTY in /home/jeff/public_html/testsplit.php on
      line 13

      That is the last line, with the split() func. But to fix that, split
      needs regex delimiters like so:

      $blahArray = split('/|/', $val);

      (Note the slashes "/" around the pipe)


      later...
      --
      Jeffrey D. Silverman | jeffreyPANTS@jh u.edu **
      Website | http://www.newtnotes.com

      (** Drop "pants" to reply by email)

      Comment

      • Jeffrey Silverman

        #4
        Re: Could this be a PHP 4.3.6 &quot;feature&q uot;?

        On Mon, 26 Jul 2004 15:43:49 -0400, Jeffrey Silverman wrote:
        [color=blue]
        > That is the last line, with the split() func. But to fix that, split
        > needs regex delimiters like so:
        >
        > $blahArray = split('/|/', $val);
        >
        > (Note the slashes "/" around the pipe)[/color]

        Ooops!! I spoke wrongly about split()!

        You need to ESCAPE the pipe with a backslash in split(), NOT provide regex
        delimiters!

        Corrected code:
        $blahArray = split('\|', $val);


        later...

        --
        Jeffrey D. Silverman | jeffreyPANTS@jh u.edu **
        Website | http://www.newtnotes.com

        (** Drop "pants" to reply by email)

        Comment

        Working...