php-general Digest 5 Nov 2011 02:21:41 -0000 Issue 7553

Topics (messages 315593 through 315594):

pcre little problem
        315593 by: QI.VOLMAR QI

Re: What's the problem with this PHP code?
        315594 by: tamouse mailing lists

Administrivia:

To subscribe to the digest, e-mail:
        php-general-digest-subscr...@lists.php.net

To unsubscribe from the digest, e-mail:
        php-general-digest-unsubscr...@lists.php.net

To post to the list, e-mail:
        php-gene...@lists.php.net


----------------------------------------------------------------------
--- Begin Message ---
i have this part of code that works with DOMDocument:

public function translateNFeXML(NFE $nfe_factory) {
        $inf_adic = $nfe_factory->createElement('infAdic');
        if ($this->inf_ad_fisco) {
            $inf_adic_fisco =
$nfe_factory->createElement('infAdicFisco', $this->inf_ad_fisco);
            $inf_adic->appendChild($inf_adic_fisco);
        }

        $string = "a=10&b[]=20&c=30n°&d=40+:50";
        die(preg_filter('/[^:][[:punct:]]/', '', $string));
        $inf_cpl = $nfe_factory->createElement('infCpl',
$this->inf_complementar);

QUESTION: Why the preg_filter causes a end of the application, with no
error throwing (even in die don't appears nothing)?

--- End Message ---
--- Begin Message ---
On Fri, Nov 4, 2011 at 2:52 AM, shiplu <shiplu....@gmail.com> wrote:
> On Fri, Nov 4, 2011 at 1:47 PM, Sophia <red_an...@techno-info.com> wrote:
>
>> Here is the PHP code:
>>
>>
>> <?php
>>
>>
>> $panka = "   c:can-it-rock-
>>    :the-boat-of-
>> :love-  ";
>>
>> $pankb = preg_split(':',$panka);
>>
>
> It should be preg_split('/:/', $panka);

Maybe just to unpack this a bit more, preg_split expects a regex in
the first parameter. When you said ':' it thought that you were
beginning a regex form with the colon and expected to find another one
to end the regex. when you do it this way, regexes have to be quoted
as well, as they are strings.


>
>
>
>> $pankc = $pankb{"1"};
>>
>> echo "(" . $panka . ")\n(" . $pankc . ")\n";
>>
>>
>> ?>
>>
>>
>>
>>
>>
>>
>> I keep getting the following error:
>>
>> Sophia-Shapiras-MacBook-Pro:**tmp red_angel$
>> Sophia-Shapiras-MacBook-Pro:**tmp red_angel$ php testo.php
>>
>> Warning: preg_split(): No ending delimiter ':' found in
>> /Users/red_angel/tmp/testo.php on line 8
>> (   c:can-it-rock-
>>    :the-boat-of-
>> :love-  )
>> ()
>> Sophia-Shapiras-MacBook-Pro:**tmp red_angel$
>> Sophia-Shapiras-MacBook-Pro:**tmp red_angel$
>>
>>
>>
>>
>> So --- what am I missing? What am I doing wrong? I'm pulling my hair out
>> over this one! Anyone have a clue what's up? I can see that the colon is
>> present *multiple* times in the string that is meant to be split! How come
>> PHP's preg_split() function can't see it?
>>
>> Thanks,
>> Sophia
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>
>
>
> --
> Shiplu Mokadd.im
> Follow me, http://twitter.com/shiplu
> Innovation distinguishes between follower and leader
>

--- End Message ---

Reply via email to