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?

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);

Archived

This topic is now archived and is closed to further replies.

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