PHP code help of text formatting

Discussion in 'PHP' started by smartcard, Jan 18, 2007.

  1. #1
    I have a PHP script giving the information of cars, and following is the code. How can I bold only the labels of the data?

    
    $ShowInfo = "<table border=0 align=center width=\"100%\">\n\t<tr>\n\t<td width=\"60%\" valign=top><font size=3 face=verdana color=black><b>$a1[VehicleName] $a1[VehicleModel]</b>
    <br>Year: $a1[VehicleYear]
    <br>Mileage: $a1[mileage] miles
    <br>Colour: $a1[VehicleColor]
    <br>First Reg. Date: $a1[firstreg]
    <br>Engine Power: $a1[cc]
    <br>Chassis No: $a1[chassis]
    <br>Engine No: $a1[engine]
    <br>Transmission: $a1[trans]
    <br>Drive Side : $a1[driveside]
    <br></font></td>\n\t<td width=\"40%\" valign=top align=center><font size=2 face=verdana color=blue ><B>Price: $MyPrice</td>\n</tr>\n\n<tr>\n\t<td valign=top><br><b>Car ID: $a1[ListingID]</b><br><br>$desc<br>";
    
    Code (markup):
     
    smartcard, Jan 18, 2007 IP
  2. krakjoe

    krakjoe Well-Known Member

    Messages:
    1,795
    Likes Received:
    141
    Best Answers:
    0
    Trophy Points:
    135
    #2
    clean up the html so that it's all the same, then try something like

    
    $ShowInfo =  preg_replace("/([a-zA-Z0-9 ]+):/", "<b>$1 :</b>", $ShowInfo );
    
    PHP:
     
    krakjoe, Jan 18, 2007 IP
  3. West

    West Peon

    Messages:
    79
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Like so:

    
    $ShowInfo = "<table border=0 align=center width=\"100%\">\n\t<tr>\n\t<td width=\"60%\" valign=top><font size=3 face=verdana color=black><b>$a1[VehicleName] $a1[VehicleModel]</b>
    <br><b>Year:</b> $a1[VehicleYear]
    <br><b>Mileage:</b> $a1[mileage] miles
    <br><b>Colour:</b> $a1[VehicleColor]
    <br><b>First Reg. Date:</b> $a1[firstreg]
    <br><b>Engine Power:</b> $a1[cc]
    <br><b>Chassis No:</b> $a1[chassis]
    <br><b>Engine No:</b> $a1[engine]
    <br><b>Transmission:</b> $a1[trans]
    <br><b>Drive Side :</b> $a1[driveside]
    <br></font></td>\n\t<td width=\"40%\" valign=top align=center><font size=2 face=verdana color=blue ><B>Price:</b> $MyPrice</td>\n</tr>\n\n<tr>\n\t<td valign=top><br><b>Car ID: $a1[ListingID]</b><br><br>$desc<br>";
    Code (markup):
    I believe this is what you were looking for anyways. :)
     
    West, Jan 18, 2007 IP