Switch erbij zette ?
Kleine Vragen Topic #1
Nielsie schreef:Hoe bedoel jeSwitch erbij zette ?
???Google eff 

oke 
Maar dat is toch niet handig als ik heel veel van die dingen krijg??
Dus stel ik heb 100opties. Dan is het niet handig om 100x die case te schrijven

Maar dat is toch niet handig als ik heel veel van die dingen krijg??
Dus stel ik heb 100opties. Dan is het niet handig om 100x die case te schrijven

Er zullen vader andere opties zijn, Kan alleen niet zo snel iets bedenken
Milan schreef:Hey Milan,Weet iemand hoe je substr() kan gebruiken zonder html-tags te breken zegmaar?
ik verveelde me, leek me wel leuke opdracht.
Hier issie:
[COLOR= #0000BB]<?php[/COLOR]
[COLOR= #007700]function[/COLOR] subStrNoTags[COLOR= #007700]([/COLOR][COLOR= #0000BB]$string[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$before[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$after[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]0[/COLOR][COLOR= #007700]) {[/COLOR]
[COLOR= #0000BB]$chars[/COLOR] [COLOR= #007700]=[/COLOR] str_split[COLOR= #007700]([/COLOR][COLOR= #0000BB]$string[/COLOR][COLOR= #007700]);[/COLOR]
[COLOR= #0000BB]$charsNoTags[/COLOR] [COLOR= #007700]=[/COLOR] str_split[COLOR= #007700]([/COLOR][URL="http://www.php.net/strip_tags"]strip_tags[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$string[/COLOR][COLOR= #007700]));[/COLOR]
[COLOR= #0000BB]$i[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]0[/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #0000BB]$result[/COLOR] [COLOR= #007700]=[/COLOR] null[COLOR= #007700];[/COLOR]
[URL="http://www.php.net/foreach"]foreach[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$chars[/COLOR] [COLOR= #007700]as[/COLOR] [COLOR= #0000BB]$key[/COLOR] [COLOR= #007700]=>[/COLOR] [COLOR= #0000BB]$char[/COLOR][COLOR= #007700]) {[/COLOR]
[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$char[/COLOR] [COLOR= #007700]==[/COLOR] [COLOR= #DD0000]"<"[/COLOR][COLOR= #007700]) {[/COLOR]
[COLOR= #0000BB]$htmlOpen[/COLOR] [COLOR= #007700]=[/COLOR] true[COLOR= #007700];
}[/COLOR]
[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$char[/COLOR] [COLOR= #007700]==[/COLOR] [COLOR= #DD0000]">"[/COLOR][COLOR= #007700]) {[/COLOR]
[COLOR= #0000BB]$htmlOpen[/COLOR] [COLOR= #007700]=[/COLOR] false[COLOR= #007700];[/COLOR]
[COLOR= #0000BB]$result[/COLOR] [COLOR= #007700].=[/COLOR] [COLOR= #0000BB]$char[/COLOR][COLOR= #007700];
}[/COLOR]
[URL="http://www.php.net/else"]else[/URL] [URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$htmlOpen[/COLOR] [COLOR= #007700]===[/COLOR] false[COLOR= #007700]) {[/COLOR]
[COLOR= #0000BB]$i[/COLOR][COLOR= #007700]++;[/COLOR]
[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$i[/COLOR] [COLOR= #007700]>=[/COLOR] [COLOR= #0000BB]$before[/COLOR] [COLOR= #007700]+[/COLOR] [COLOR= #0000BB]1[/COLOR] [COLOR= #007700]&&[/COLOR] [COLOR= #0000BB]$i[/COLOR] [COLOR= #007700]<=[/COLOR] [URL="http://www.php.net/count"]count[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$charsNoTags[/COLOR][COLOR= #007700]) - ([/COLOR][COLOR= #0000BB]$after[/COLOR] [COLOR= #007700]* -[/COLOR][COLOR= #0000BB]1[/COLOR][COLOR= #007700])) {[/COLOR]
[COLOR= #0000BB]$result[/COLOR] [COLOR= #007700].=[/COLOR] [COLOR= #0000BB]$char[/COLOR][COLOR= #007700];
}
}[/COLOR]
[URL="http://www.php.net/else"]else[/URL] [COLOR= #007700]{[/COLOR]
[COLOR= #0000BB]$result[/COLOR] [COLOR= #007700].=[/COLOR] [COLOR= #0000BB]$char[/COLOR][COLOR= #007700];
}
}[/COLOR]
[URL="http://www.php.net/return"]return[/URL] [COLOR= #0000BB]$result[/COLOR][COLOR= #007700];
}[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] subStrNoTags[COLOR= #007700]([/COLOR][COLOR= #DD0000]"<b>Tekst <i>hiero<i></b>"[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]1[/COLOR][COLOR= #007700], -[/COLOR][COLOR= #0000BB]4[/COLOR][COLOR= #007700]);[/COLOR] Geeft: ekst h
^ Mooie snippet. Kan nog wel van pas komen.
Freestyle schreef:Maar dat lukt nietC# vraag:
Ik ben bezig met een rekenmachine.
en dan heb ik 2 getallen in 2 vars:
var getal1 = 10;
var getal2 = 4;
var methode = "+";
Hoe laat ik dat dan rekenenheb al van alles geprobeerd maar het lukt niet. En op et internet krijg ik niet de oplossing hoe ik het wil.
Ik probeer bijv:output.Text = getal1.methode.getal2;

Op het internet vind ik:
output.Text = getal1 + getal2; Maar mijn var van methode kan van alles zijn. Bijv: +, -, /, *
Hoe kan ik zorgen dat hij gaat rekenen
??if(methode == "+") {
output.Text = getal1 + getal2 // ZONDER PUNTKOMMA!
}
Maar dan met case dus.
Antonn schreef:if(methode == "+") {Ik ben bezig met een rekenmachine.Eerdere citaten tonen
Freestyle schreef:C# vraag:
en dan heb ik 2 getallen in 2 vars:
var getal1 = 10;
var getal2 = 4;
var methode = "+";
Hoe laat ik dat dan rekenenheb al van alles geprobeerd maar het lukt niet. En op et internet krijg ik niet de oplossing hoe ik het wil.
Ik probeer bijv:output.Text = getal1.methode.getal2;
Maar dat lukt niet
Op het internet vind ik:output.Text = getal1 + getal2;
Maar mijn var van methode kan van alles zijn. Bijv: +, -, /, *
Hoe kan ik zorgen dat hij gaat rekenen??
output.Text = getal1 + getal2 // ZONDER PUNTKOMMA!
}
Maar dan met case dus.
Intalen anders dan php moet j heel erg rekening houden met de datatype, wat je trouwens volgens mij beter kan doen is een switch maken.
Ohja, dit bedoel ik
if methode = "+" then
output.Text = getal1 + getal2 // ZONDER PUNTKOMMA!
end if
Ja sorry, mijn fout xD
Maar beter case indd. Gwn ff googlen.
if methode = "+" then
output.Text = getal1 + getal2 // ZONDER PUNTKOMMA!
end if
Ja sorry, mijn fout xD
Maar beter case indd. Gwn ff googlen.
hoe herschrijf je ?p=pagina/news naar ?p=news
Jvdw schreef:.htaccess modrewritehoe herschrijf je ?p=pagina/news naar ?p=news
http://www.jwbobbink.nl/bobbink/seo-tips/urls-herschrijven-met-mod_rewrite-in-htaccess-bestand/
Jvdw schreef:Maak er dan meteen /news van ofzo?hoe herschrijf je ?p=pagina/news naar ?p=news

Je kunt dat trouwens veel beter in PHP zelf regelen ipv htaccess.
Lennard schreef:Hoe dan? Je moet toch elke URL dan doorverwijzen naar je index of een ander bestand d.m.v. de htaccess? En gaat dat in het algemeen niet sneller met een htaccess?Maak er dan meteen /news van ofzo?Eerdere citaten tonen
Jvdw schreef:hoe herschrijf je ?p=pagina/news naar ?p=news
Je kunt dat trouwens veel beter in PHP zelf regelen ipv htaccess.
Die ?p= handel je toch af in PHP?
Je doet zoiets:
include_once $_GET[p]..php;
dus daar maak je dit van:
include_once pagina/.$_GET[p]..php;
of desnoods:
$_GET[p] = pagina/.$_GET[p];
Je doet zoiets:
include_once $_GET[p]..php;
dus daar maak je dit van:
include_once pagina/.$_GET[p]..php;
of desnoods:
$_GET[p] = pagina/.$_GET[p];