Search found 9 matches

by aos24
Fri Feb 09, 2007 9:55 pm
Forum: PHP - Code
Topic: file_get_contents cookie?
Replies: 7
Views: 793

You might want to check out CURL, which supports this kind of functionality.
by aos24
Fri Feb 09, 2007 9:21 pm
Forum: PHP - Code
Topic: str_replace with search and replace arrays
Replies: 3
Views: 607

Thanks. But what about the "order of replacement" functionality -- i.e., the guarantee that the array elements are processed in order -- has that been in place since 4.0.5?
by aos24
Fri Feb 09, 2007 8:41 pm
Forum: PHP - Code
Topic: str_replace with search and replace arrays
Replies: 3
Views: 607

str_replace with search and replace arrays

The current PHP manual gives the following example for str_replace: // Order of replacement $str = "Line 1\nLine 2\rLine 3\r\nLine 4\n"; $order = array("\r\n", "\n", "\r"); $replace = '<br />'; // Processes \r\n's first so they aren't converted twice. $newstr ...
by aos24
Wed Feb 07, 2007 3:59 pm
Forum: PHP - Code
Topic: Strings: best practice?
Replies: 12
Views: 510

Thanks, volka, that was very helpful. Great FAQ, too.
by aos24
Tue Feb 06, 2007 7:03 pm
Forum: PHP - Code
Topic: Strings: best practice?
Replies: 12
Views: 510

I really don't want to get down and dirty with the garbage collector! What I want to do is to establish good coding practices for strings, so that if there are several comparable approaches to a programming task I can choose the one that will wreak the least havoc under the covers. Once I've done th...
by aos24
Tue Feb 06, 2007 6:38 pm
Forum: PHP - Code
Topic: Strings: best practice?
Replies: 12
Views: 510

I could do that, but I was hoping someone here would just know, and would be able to say either, "Yes, updating strings in place is considered good practice", or, "Don't do that: it will work but you'll create lots of temporary strings for the garbage collector to clean up!"
by aos24
Tue Feb 06, 2007 6:00 pm
Forum: PHP - Code
Topic: Strings: best practice?
Replies: 12
Views: 510

Thanks, but how am I supposed to reliably determine what the garbage collector is doing?
by aos24
Tue Feb 06, 2007 5:17 pm
Forum: PHP - Code
Topic: Strings: best practice?
Replies: 12
Views: 510

Thanks. I don't think you can assign to substr() -- I get "Can't use function return value in write context" when I try it. So would, say, updating several hundred characters in a 1-4K string using $message[$i] = $newchar be reasonably efficient? (I.e., it wouldn't create hundreds of copie...
by aos24
Tue Feb 06, 2007 4:50 pm
Forum: PHP - Code
Topic: Strings: best practice?
Replies: 12
Views: 510

Strings: best practice?

I know that it's possible to update a character of a string in place -- e.g. $message[4] = 'T' -- but is this considered best practice? Are PHP strings mutable? (If not, would the interpreter create a separate copy of the entire $message string when the above code is executed?)

Thanks.