Jump to content

[SOLVED] bolding array values


asmith

Recommended Posts

Now, do you only wants it to be replaced when it's actually its own word, or does it not matter where in a word it is?

 

I.E:

$content = array('test');

$string = "We have a new contestant!";

//replace stuff

echo $string;

 

And it echos: We have a new con<b>test</b>ant!  Is that what you want?

Link to comment
Share on other sites

I realize that you posted this in regex, but if you just want to bold each element in the array you could:

 

<?php
$testarray = array('this', 'will', 'be', 'bolded');
$boldarray = array_map('boldarray', $testarray);

function boldarray($el){
    return '<b>' . $el . '</b>';
}
print_r($boldarray);

Link to comment
Share on other sites

Thanks little guy :)

 

just one thing.  your code does not fint the words  this  :

 

$string = 'this is a test string, about a thephp mountains';

 

 

When they are sticked after or before or in a word. (I made those letter italic)

 

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

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

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  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...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.