Jump to content
php.lv forumi

preg replace


Recommended Posts

Ar kādu funkciju var noteikt cik aizvietošanas ir veiktas?


$patterns[1] = '/:nosaukums:/';
$replacements[1] = '<img src=img/atels.gif>';
$patterns[2] = '/:nosaukums2:/';
$replacements[2] = '<img src=img/atels2.gif>';
$patterns[3] = '/:nosaukums3:/';
$replacements[3] = '<img src=img/atels3.gif>';

$text = preg_replace($patterns, $replacements, $text);


un ja ir vairāk par 2 aizvietošanām, izvada tikai pirmās divas.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...