hackerkts Posted October 30, 2006 Share Posted October 30, 2006 Let's say I have this,[code]$type1 = '5'; // all the values are in %$type2 = 15'';$type3 = 20'';$type4 = 50'';$type5 = 10'';[/code]Is it possible to assign them to$type1_result = '11111';$type2_result = '222222222222222';$type3_result = '33333333333333333333';$type4_result = '44444444444444444444444444444444444444444444444444';$type5_resul = '5555555555';Hope you understand what I'm trying to say.. Link to comment https://forums.phpfreaks.com/topic/25536-about-percentage/ Share on other sites More sharing options...
trq Posted October 30, 2006 Share Posted October 30, 2006 [quote]Hope you understand what I'm trying to say..[/quote]Nope... sorry. Link to comment https://forums.phpfreaks.com/topic/25536-about-percentage/#findComment-116524 Share on other sites More sharing options...
hackerkts Posted October 30, 2006 Author Share Posted October 30, 2006 Hmm ok, I will explain again..If I put $A = 10;Then I had another var, which is what I couldn't figure out myself.Let's say that var is $A_Result, then I want the vaule of $A_Result to be AAAAAAAAAA. (There are 10's A)So the value of $A_Result is depended on the value of $A.Hmm.. Is this clear ?To make it more clearer, this is the code I'm using now.[code] function rtd($length){ $dice1 = '5'; // Dice 1 $dice2 = '15'; // Dice 2 $dice3 = '20'; // Dice 3 $dice4 = '50'; // Dice 4 $dice5 = '10'; // Dice 5 $dice6 = '0'; // Dice 6 $chars = $dice1 . $dice2 . $dice3 . $dice4 . $dice5 . $dice6; for ($x = 1; $x <= $length; $x++) { $number = rand(1, strlen($chars)); $dice .= substr($chars, $number - 1, 1); } return $dice;}[/code]Then when I echo out $dice, there's 5% will be Dice 1, 15% to be Dice 2, 20% to be Dice 3, 50% to be Dice 4, 10% to be Dice 5 and 0% to be Dice 6 Link to comment https://forums.phpfreaks.com/topic/25536-about-percentage/#findComment-116530 Share on other sites More sharing options...
fert Posted October 30, 2006 Share Posted October 30, 2006 [code]for($count=0;$count<10;$count++){ $result.=$a;}[/code] Link to comment https://forums.phpfreaks.com/topic/25536-about-percentage/#findComment-116535 Share on other sites More sharing options...
spfoonnewb Posted October 30, 2006 Share Posted October 30, 2006 [code]<?phpfor ($A = 1; $A <= 10; ++$A) //Display 10 of the following{ echo 'A '; //10 What? 10 A's!}?>[/code] Link to comment https://forums.phpfreaks.com/topic/25536-about-percentage/#findComment-116536 Share on other sites More sharing options...
trq Posted October 30, 2006 Share Posted October 30, 2006 Still a bit lost. Something like....[code=php:0]<?php $a = 10; $a_result = 'a'; echo str_pad($a_result,$a_result,$a);?>[/code]Maybe the question I should ask is why? What exactly are you trying to do? Link to comment https://forums.phpfreaks.com/topic/25536-about-percentage/#findComment-116537 Share on other sites More sharing options...
hackerkts Posted October 30, 2006 Author Share Posted October 30, 2006 Just updated my previous post, hope it is clear enough.Ok sorry, I got to work. I will read it again after I return home.And thanks for all your helps. Link to comment https://forums.phpfreaks.com/topic/25536-about-percentage/#findComment-116538 Share on other sites More sharing options...
hackerkts Posted October 30, 2006 Author Share Posted October 30, 2006 Ok, I'm back from work.Hey fert, thanks for enlighten me.I forgotten about the .$result[b].[/b]=$a;And thanks for all your helps again. Cheers :) Link to comment https://forums.phpfreaks.com/topic/25536-about-percentage/#findComment-116770 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.