Log in

View Full Version : PHP Question


Kingofl337
25-01-2007, 16:21
I want to print a number string but I'm having trouble.

$Value = '1234';
$Print_Value = $Current_Version[0] . $Current_Version[1] . $Current_Version[2] . $Current_Version[3] ;
echo ("$Print-Value");

I want it to print 1.2.3.4.

I know that $ST=$STR.$STR1 combines strings but I can't figure how to
get the desired output.

Joel J
25-01-2007, 16:26
$a = 'bre';
$b = 'athe';

$out = $a.$b; // $out = breathe
$out = $a . '.' . $b; // $out = bre.athe

You need to also "dot" in the period. Even with that I still don't fully understand your question.. do you want to print the value in $Value, with periods between all the numbers, or are the digits in CurrentVersion?

Kingofl337
25-01-2007, 16:30
rock on! Thanks!

felipe.tonello
25-01-2007, 16:36
<?
$Value = '1234';
$Print_Value = '';
for ($i = 0; $i < strlen($Value); $i++){
if ($i != (strlen($Value) - 1))
$Print_Value .= $Value{$i} . '.';
else
$Print_Value .= $Value{$i};
}

echo $Print_Value;
?>

I believe is something like that, you are waiting for..
just feedback if don't..

:)

Kingofl337
25-01-2007, 16:40
Ok one more :)


$Print_Version = $Current_Version[0].'.'.$Current_Version[1].'.'.$Current_Version[2].'.'.$Current_Version[3];
$comment='<font color="red"><b>'.$Print_Version.'</b></font>';



I need the output to be in red 1.2.3.4
It's sending out 1234 in red

Brandon Martus
25-01-2007, 16:44
Ok one more :)


$Print_Version = $Current_Version[0].'.'.$Current_Version[1].'.'.$Current_Version[2].'.'.$Current_Version[3];
$comment='<font color="red"><b>'.$Current_Version.'</b></font>';



I need the output to be in red 1.2.3.4
It's sending out 1234 in red
Change the $Current_Version in your second line to $Print_Version and you should be ok, if I'm understanding right.

Kingofl337
25-01-2007, 17:09
Thanks for the idea, but, that didn't fix it. I Just copied it wrong. It's still printing 1234 instead of 1.2.3.4

Cuog
25-01-2007, 19:45
wouldn't this work?


echo "$val[1].$val[2].$val[3].$val[4]";

pheadxdll
25-01-2007, 20:46
If you'd like to get fancy:


// I like p instead of font :)
echo "<p style='color: red;'><b>";
foreach($Current_Version as $value) {
echo "$value.";
}
echo "</b></p>";


There's probley other simple ways but meh its something to try if your stuck.