Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Website Design/Showcase (http://www.chiefdelphi.com/forums/forumdisplay.php?f=64)
-   -   PHP Question (http://www.chiefdelphi.com/forums/showthread.php?t=52734)

Kingofl337 25-01-2007 16:21

PHP Question
 
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

Re: PHP Question
 
$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

Re: PHP Question
 
rock on! Thanks!

felipe.tonello 25-01-2007 16:36

Re: PHP Question
 
PHP Code:

<?
$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

Re: PHP Question
 
Ok one more :)

Code:

$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

Re: PHP Question
 
Quote:

Originally Posted by Kingofl337 (Post 565086)
Ok one more :)

Code:

$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

Re: PHP Question
 
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

Re: PHP Question
 
wouldn't this work?


Code:

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

pheadxdll 25-01-2007 20:46

Re: PHP Question
 
If you'd like to get fancy:

PHP Code:

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


All times are GMT -5. The time now is 16:32.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi