Forum Moderators: coopster

Message Too Old, No Replies

Periods

         

createErrorMsg

2:26 am on Oct 20, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



How can I put a literal period (.) in a string value stored in an array?

$hrefs[0] = array("link" => "test.php?id=one", "id" => "one");

The period in 'test.php' is preventing the script from even running. In JS, I would just escape it with a back slash, but this doesn't do the trick in PHP. I've been running searches on php.net for an hour now and coming up empty.

I assume I'm missing some simple, but critical, part...how can I write that line so that the period is stored as part of the value in the array without sending the whole script into a tizzy?

Thanks for your help and consideration.
cEM

JamesRock

2:33 am on Oct 20, 2004 (gmt 0)

10+ Year Member



That code should (and does) work fine:


$hrefs[0] = array("link" => "test.php?id=one", "id" => "one");
var_dump($hrefs);

Gives me:


array(1) {
[0]=>
array(2) {
["link"]=>
string(15) "test.php?id=one"
["id"]=>
string(3) "one"
}
}

What error message are you getting? This definitely shouldn't happen I'd say there's something wrong with your PHP setup to cause a problem like this.

createErrorMsg

2:54 am on Oct 20, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



James, thanks a lot for your speedy reply. I think I figured out the problem, and you're right: it had nothing to do with those lines of code. A for loop elsewhere in the script was changing information in the array and nullifying it's values.

Sorry to have wasted your time. I think I posted a little hastily. Again, thanks for your response.

cEM