Re: replacing part of string with values in array
| From: | Brian White | Date: | Thu, 12 Jul 2001 23:40:11 +0000 |
| Subject: | Re: replacing part of string with values in array | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-57651@lists.php.net to get a copy of this message | ||
Shoot from the hip response... untested....
function resolveParts( $str, $partsArray )
{
// explode the original $str based on 'PART'
$stringBits = explode( 'PART', $str );
//Ok. So now we have two arrays. The length of partsArray
// should be one less than stringBits
$blended = array( array_shift( $stringBits ));
while ( $stringBits )
{
$blended[] = array_shift( $partsArray );
$blended[] = array_shift( $stringBits );
}
return implode( $blended, "" );} At 01:30 13/07/2001 +0200, Gregor Jaksa wrote:
hello, ok heres the thing ;) lets say i have array("part1", "part2", "part3", "part4"); now i have string like $string = "here's PART and heres PART, another PART here and final PART here"; now i wanna replace first PART in string with part1 from array and second PART with part2 from array ... one more thing is that i dont know how many parts there will be in string .. but i know that array and string will have the same number of parts ;) help plz :) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net For additional commands, e-mail: php-general-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net------------------------- Brian White Step Two Designs Pty Ltd - SGML, XML & HTML Consultancy Phone: +612-93197901 Web: http://www.steptwo.com.au/ Email: bwhite@steptwo.com.au