What's the problem with this PHP code?
| From: | Sophia | Date: | Fri, 04 Nov 2011 07:47:42 +0000 |
| Subject: | What's the problem with this PHP code? | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-315590@lists.php.net to get a copy of this message | ||
Here is the PHP code:
<?php
$panka = " c:can-it-rock-
:the-boat-of-:love- "; $pankb = preg_split(':',$panka); $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