Hoe een ID toevoegen?

Gestart doorAllard7 reacties39 weergaven

8 berichten · pagina 1 van 1

Allard

Lid · Topicstarter

Berichten
970
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Beste,

Ik zit een beetje vast. Hoe kan ik hieronder een ID toevoegen? Ik wil dat er een gatal vanaf 0 komt te staan. En als het er 2 zijn, dat er staat 0 en dan een 1. Hieronder zie je wat ik bedoel:

Mijn huidige code:

[COLOR= #0000BB]<?php[/COLOR]
[URL="http://www.php.net/foreach"]foreach[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$result[/COLOR] [COLOR= #007700]as[/COLOR] [COLOR= #0000BB]$value[/COLOR] [COLOR= #007700]=>[/COLOR] [COLOR= #0000BB]$key[/COLOR][COLOR= #007700]){[/COLOR]
           [COLOR= #0000BB]$results[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/explode"]explode[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000] [/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$key[/COLOR][COLOR= #007700]);[/COLOR]
           [URL="http://www.php.net/print"]print[/URL] [COLOR= #DD0000]"<cronjob><id></id><day>$results[0]</day><hour>$results[1]</hour><monthday>$results[2]</monthday><month>$results[3]</month><weekday>$results[4]</weekday><command>$results[5]</command></cronjob>"[/COLOR][COLOR= #007700];
       }[/COLOR]
?>


Ouput:

<cronjob><id></id><day>1</day><hour>2</hour><monthday>3</monthday><month>5</month><weekday>6</weekday><command>/home/allard/</command></cronjob>
<cronjob><id></id><day>4</day><hour>2</hour><monthday>1</monthday><month>5</month><weekday>6</weekday><command>/home/allard/</command></cronjob>


Maar ik wil dat als output:

<cronjob><id>0</id><day>1</day><hour>2</hour><monthday>3</monthday><month>5</month><weekday>6</weekday><command>/home/allard/</command></cronjob>
<cronjob><id>1</id><day>4</day><hour>2</hour><monthday>1</monthday><month>5</month><weekday>6</weekday><command>/home/allard/</command></cronjob>
0
Berichten
2.692
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
[COLOR= #0000BB]<?php
$bas[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]0[/COLOR][COLOR= #007700];[/COLOR]
[URL="http://www.php.net/foreach"]foreach[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$result[/COLOR] [COLOR= #007700]as[/COLOR] [COLOR= #0000BB]$value[/COLOR] [COLOR= #007700]=>[/COLOR] [COLOR= #0000BB]$key[/COLOR][COLOR= #007700]){[/COLOR]
           [COLOR= #0000BB]$results[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/explode"]explode[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000] [/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$key[/COLOR][COLOR= #007700]);[/COLOR]
           [URL="http://www.php.net/print"]print[/URL] [COLOR= #DD0000]"<cronjob><id>"[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$bas[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000]"</id><day>$results[0]</day><hour>$results[1]</hour><monthday>$results[2]</monthday><month>$results[3]</month><weekday>$results[4]</weekday><command>$results[5]</command></cronjob>"[/COLOR][COLOR= #007700];[/COLOR]
           [COLOR= #0000BB]$bas[/COLOR][COLOR= #007700]++;
       }[/COLOR]
?>
0
Berichten
93.699
Reputatie
0
Punten
1,27
Lid sinds
Laatst gezien
Variabelen buiten quotes!!!
0
Berichten
2.692
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Raoulfloks schreef:
Variabelen buiten quotes!!!
En wtf bedoel je daarmeeemo?
0
Berichten
93.699
Reputatie
0
Punten
1,27
Lid sinds
Laatst gezien
Superb schreef:
Eerdere citaten tonen
Raoulfloks schreef:
Variabelen buiten quotes!!!
En wtf bedoel je daarmeeemo?
Dat het niet

[COLOR= #0000BB]<?php
$var[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]"hoi"[/COLOR][COLOR= #007700];[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"$var lol"[/COLOR][COLOR= #007700];[/COLOR]
?>


dat moet zijn maar

[COLOR= #0000BB]<?php
$var[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]"hoi"[/COLOR][COLOR= #007700];[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$var[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000]"lol"[/COLOR][COLOR= #007700];[/COLOR]
?>
0
Berichten
2.692
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Ik heb dat van mij met dat $value toch goed gedaan? Ik heb de rest laten staan zoals het was emo
0
Allard

Lid · Topicstarter

Berichten
970
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Je kan variabeles gewoon binnen een print doen hoor?
0
Rik

Lid

Berichten
18.393
Reputatie
0
Punten
0,04
Lid sinds
Laatst gezien
Allard schreef:
Je kan variabeles gewoon binnen een print doen hoor?
Maar dat is slecht, en bovendien errorgevoeliger en onoverzichtelijker
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