Re: Script feedback: insert string into another string

From: Date: Sat, 28 Apr 2007 09:29:13 +0000
Subject: Re: Script feedback: insert string into another string
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-254051@lists.php.net to get a copy of this message
Tijnema! Thanks for the quick reply! I really really really appreciate the help. :D Tijnema ! wrote:
Nice idea, but it seems that it isn't working correctly. I did this example: <?php for($x = 0; $x < 100; $x++) { $string .= " abc"; } echo break_up($string, 10, "||"); ?> With your break_up function. It results this: ...<snip>... While i expected this: ...</snip>...
Ahhhhhh! Great way to test this! I thought I noticed a problem, but did not put two-and-two together due to the huge string I was using... The way you simplified things really made that error clear. Thanks for the help on this! :)
And i found where the problem is, it is this line: $num += $num; // Set next number flag to look for. This works only for one time, but after that, it doubles whole time, so in above example, $num would go like this: 10 20 40 80
Doh! Great catch! I should have printed that var out... Hehe, I am such a noob!
So to fix, replace this part of the code: ...<snip>... with this: ...<snip>... That's it.
Woot! Looks good to me. I moved the script to a new location with a more fitting name: <http://www.ambiguism.com/sandbox/insert/insert.php> Your test code is at bottom of that page. ;) Nice, I am stoked! Thanks again for the help, I owe you one. :D Have a great day/night, Cheers, Micky -- Wishlists: <http://snipurl.com/1gqpj> Switch: <http://browsehappy.com/> BCC?: <http://snipurl.com/w6f8> My: <http://del.icio.us/mhulse>

« previous php.general (#254051) next »