nummers scheiden met -

Gestart doorJoeryy18 reacties59 weergaven

19 berichten · pagina 1 van 2

Joeryy

Lid · Topicstarter

Berichten
1.533
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Hey,

Ik heb nu een getal zoals dit: 6883563329465687 En nu wil ik dit delen in 4 stukken met een streepje. Ik kan helaas niks vinden op google.

Poedeltje.
0
Berichten
35.796
Reputatie
1
Punten
0,00
Lid sinds
Laatst gezien
[COLOR= #0000BB]<?php
$int[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]6883563329465687[/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #0000BB]$lengte[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/strlen"]strlen[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$int[/COLOR][COLOR= #007700]);[/COLOR]

[COLOR= #0000BB]$delen[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$lengte[/COLOR] / [COLOR= #0000BB]4[/COLOR][COLOR= #007700];[/COLOR]

[URL="http://www.php.net/echo"]echo[/URL] [URL="http://www.php.net/wordwrap"]wordwrap[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$int[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$delen[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #DD0000]-[/COLOR][COLOR= #007700]);[/COLOR]


Zoiets?

Kan het niet testen want ik moet eten. biggrin
toevoeging op 28 augustus 2012, 17:49:43:
Misschien moet je dat getal tussen quotes doen, weet niet of PHP grote getallen kan handelen.
0
Joeryy

Lid · Topicstarter

Berichten
1.533
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Lennard schreef:
[COLOR= #0000BB]<?php
$int[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]6883563329465687[/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #0000BB]$lengte[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/strlen"]strlen[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$int[/COLOR][COLOR= #007700]);[/COLOR]

[COLOR= #0000BB]$delen[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$lengte[/COLOR] / [COLOR= #0000BB]4[/COLOR][COLOR= #007700];[/COLOR]

[URL="http://www.php.net/echo"]echo[/URL] [URL="http://www.php.net/wordwrap"]wordwrap[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$int[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$delen[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #DD0000]-[/COLOR][COLOR= #007700]);[/COLOR]
Zoiets?

Kan het niet testen want ik moet eten. biggrin
toevoeging op 28 augustus 2012, 17:49:43:
Misschien moet je dat getal tussen quotes doen, weet niet of PHP grote getallen kan handelen.

Het getal blijft nu gewoon het zelfde cry
0
Berichten
35.796
Reputatie
1
Punten
0,00
Lid sinds
Laatst gezien
Zo dan:

[COLOR= #0000BB]<?php
$int[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]6883563329465687[/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #0000BB]$lengte[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/strlen"]strlen[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$int[/COLOR][COLOR= #007700]);[/COLOR]

[COLOR= #0000BB]$delen[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$lengte[/COLOR] / [COLOR= #0000BB]4[/COLOR][COLOR= #007700];[/COLOR]

[URL="http://www.php.net/echo"]echo[/URL] [URL="http://www.php.net/wordwrap"]wordwrap[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$int[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$delen[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #DD0000]-[/COLOR][COLOR= #007700],[/COLOR] true[COLOR= #007700]);[/COLOR]
0
Berichten
5.957
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
ow ja, nvm
0
Berichten
10.421
Reputatie
4
Punten
0,00
Lid sinds
Laatst gezien
Hm...

Code verwijderd, werkt niet
0
Joeryy

Lid · Topicstarter

Berichten
1.533
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Lennard schreef:
Zo dan:
[COLOR= #0000BB]<?php
$int[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]6883563329465687[/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #0000BB]$lengte[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/strlen"]strlen[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$int[/COLOR][COLOR= #007700]);[/COLOR]

[COLOR= #0000BB]$delen[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$lengte[/COLOR] / [COLOR= #0000BB]4[/COLOR][COLOR= #007700];[/COLOR]

[URL="http://www.php.net/echo"]echo[/URL] [URL="http://www.php.net/wordwrap"]wordwrap[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$int[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$delen[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #DD0000]-[/COLOR][COLOR= #007700],[/COLOR] true[COLOR= #007700]);[/COLOR]


Werkt perfect, bedankt.

toevoeging op 28 augustus 2012, 23:06:34:
Hoe kan ik daar rand() in maken, ik krijg deze error als ik het gebruik.

Warning: wordwrap() [function.wordwrap]: Cant force cut when width is zero in /home/u200810859/public_html/index.php on line 11
0
Berichten
8.649
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
intval(rand(1000000000000000, 9999999999999999))
0
Berichten
35.796
Reputatie
1
Punten
0,00
Lid sinds
Laatst gezien
Antonn schreef:
intval(rand(1000000000000000, 9999999999999999))
Die geeft geen unieke waarden meer, je kan bij die lange strings beter met een loopje een uniek getal maken.
En je moet juist geen intval hebben, want die zet het om naar de wetenschappelijke notitie, en je wil enkel getallen hebben.
0
Joeryy

Lid · Topicstarter

Berichten
1.533
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Lennard schreef:
Eerdere citaten tonen
Antonn schreef:
intval(rand(1000000000000000, 9999999999999999))
Die geeft geen unieke waarden meer, je kan bij die lange strings beter met een loopje een uniek getal maken.
En je moet juist geen intval hebben, want die zet het om naar de wetenschappelijke notitie, en je wil enkel getallen hebben.
En hoe doe ik dit confused?

toevoeging op 29 augustus 2012, 18:44:47:
Laatmaar, heb beetje geprobeerd en het lukt. (Ben slecht in php yummie)

[COLOR= #0000BB]<?php
$int[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/rand"]rand[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]1000000000000000[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]9999999999999999[/COLOR][COLOR= #007700]);[/COLOR]
[COLOR= #0000BB]$lengte[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/strlen"]strlen[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$int[/COLOR][COLOR= #007700]);[/COLOR]

[COLOR= #0000BB]$delen[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$lengte[/COLOR] / [COLOR= #0000BB]4[/COLOR][COLOR= #007700];[/COLOR]

[URL="http://www.php.net/echo"]echo[/URL] [URL="http://www.php.net/wordwrap"]wordwrap[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$int[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$delen[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #DD0000]-[/COLOR][COLOR= #007700],[/COLOR] true[COLOR= #007700]);[/COLOR]
?>


Was niet echt moeilijk eigenlijk...
0
Berichten
35.796
Reputatie
1
Punten
0,00
Lid sinds
Laatst gezien
Let dan wel op dat je op sommige systemen gekke bugs kan krijgen, op mijn Windows-computer werkt je scriptje bijvoorbeeld niet, ik krijg dan zulke outputs:
-49-25-19-51
0
Joeryy

Lid · Topicstarter

Berichten
1.533
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Lennard schreef:
Let dan wel op dat je op sommige systemen gekke bugs kan krijgen, op mijn Windows-computer werkt je scriptje bijvoorbeeld niet, ik krijg dan zulke outputs:
-49-25-19-51
Is dit oplosbaar of niet?
0
Berichten
6.485
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
ja, je kan het beter zo doen

[COLOR= #0000BB]<?php

$result[/COLOR] [COLOR= #007700]=[/COLOR] null[COLOR= #007700];[/COLOR]

[URL="http://www.php.net/for"]for[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$i[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]0[/COLOR][COLOR= #007700];[/COLOR] [COLOR= #0000BB]$i[/COLOR] [COLOR= #007700]<[/COLOR] [COLOR= #0000BB]4[/COLOR][COLOR= #007700];[/COLOR] [COLOR= #0000BB]$i[/COLOR][COLOR= #007700]++) {[/COLOR]
    [COLOR= #0000BB]$result[/COLOR] [COLOR= #007700].= ([/COLOR][COLOR= #0000BB]$i[/COLOR] [COLOR= #007700]!=[/COLOR] [COLOR= #0000BB]3[/COLOR][COLOR= #007700]) ?[/COLOR] [URL="http://www.php.net/rand"]rand[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]0[/COLOR][COLOR= #007700],[/COLOR][COLOR= #0000BB]9999[/COLOR][COLOR= #007700]).[/COLOR][COLOR= #DD0000]-[/COLOR] [COLOR= #007700]:[/COLOR] [URL="http://www.php.net/rand"]rand[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]0[/COLOR][COLOR= #007700],[/COLOR][COLOR= #0000BB]9999[/COLOR][COLOR= #007700]);
}[/COLOR]
0
Berichten
8.649
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Rogier schreef:
ja, je kan het beter zo doen
[COLOR= #0000BB]<?php

$result[/COLOR] [COLOR= #007700]=[/COLOR] null[COLOR= #007700];[/COLOR]

[URL="http://www.php.net/for"]for[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$i[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]0[/COLOR][COLOR= #007700];[/COLOR] [COLOR= #0000BB]$i[/COLOR] [COLOR= #007700]<[/COLOR] [COLOR= #0000BB]4[/COLOR][COLOR= #007700];[/COLOR] [COLOR= #0000BB]$i[/COLOR][COLOR= #007700]++) {[/COLOR]
    [COLOR= #0000BB]$result[/COLOR] [COLOR= #007700].= ([/COLOR][COLOR= #0000BB]$i[/COLOR] [COLOR= #007700]!=[/COLOR] [COLOR= #0000BB]3[/COLOR][COLOR= #007700]) ?[/COLOR] [URL="http://www.php.net/rand"]rand[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]1000[/COLOR][COLOR= #007700],[/COLOR][COLOR= #0000BB]9999[/COLOR][COLOR= #007700]).[/COLOR][COLOR= #DD0000]-[/COLOR] [COLOR= #007700]:[/COLOR] [URL="http://www.php.net/rand"]rand[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]1000[/COLOR][COLOR= #007700],[/COLOR][COLOR= #0000BB]9999[/COLOR][COLOR= #007700]);
}[/COLOR]


Beter emo
0
Berichten
6.485
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Antonn schreef:
Eerdere citaten tonen
Rogier schreef:
ja, je kan het beter zo doen
[COLOR= #0000BB]<?php

$result[/COLOR] [COLOR= #007700]=[/COLOR] null[COLOR= #007700];[/COLOR]

[URL="http://www.php.net/for"]for[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$i[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]0[/COLOR][COLOR= #007700];[/COLOR] [COLOR= #0000BB]$i[/COLOR] [COLOR= #007700]<[/COLOR] [COLOR= #0000BB]4[/COLOR][COLOR= #007700];[/COLOR] [COLOR= #0000BB]$i[/COLOR][COLOR= #007700]++) {[/COLOR]
    [COLOR= #0000BB]$result[/COLOR] [COLOR= #007700].= ([/COLOR][COLOR= #0000BB]$i[/COLOR] [COLOR= #007700]!=[/COLOR] [COLOR= #0000BB]3[/COLOR][COLOR= #007700]) ?[/COLOR] [URL="http://www.php.net/rand"]rand[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]1000[/COLOR][COLOR= #007700],[/COLOR][COLOR= #0000BB]9999[/COLOR][COLOR= #007700]).[/COLOR][COLOR= #DD0000]-[/COLOR] [COLOR= #007700]:[/COLOR] [URL="http://www.php.net/rand"]rand[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]1000[/COLOR][COLOR= #007700],[/COLOR][COLOR= #0000BB]9999[/COLOR][COLOR= #007700]);
}[/COLOR]

Beter emo
Idd beter, omdat zoals hierboven vermeld is de andere manier soms niet werkt...
0

Jouw reactie

Deel je idee, stel een vraag of help een ander verder.

Editor laden…

Praat mee met de One2xs-community.

Inloggen om te reageren