Posts by Wynn • 600 points
9 posts
-
0
votes3
answers210
viewsA: timestamp does not indicate the correct date
If the date format passed to strtotime() is not valid the function returns false. Use DateTime::createFromFormat() to convert dates to timestamp: DateTime::createFromFormat('Y-m-d H:i:s',…
-
11
votes1
answer3615
viewsA: Generate list of possible combinations
To count the games, you need to make a simple combination: function combinacaoSimples(n, p) { return (fatorial(n) / (fatorial(p) * fatorial(n-p))); } function fatorial(n) { if(n === 0 || n === 1) {…
-
2
votes3
answers3827
viewsA: How to scroll infinity with pure javascript?
Dommousescroll only works on Firefox, you also have to use onmousescroll to work on other browsers. I made an example of paging with scroll like the link you posted in jsFiddle:…
-
0
votes5
answers727
viewsA: Return all CSS classes with Regular Expression
Using regular expressions, /([^{]+)\s*\{[^}]*}/ satisfies all selectors and /\.(-?[a-z_]+[a-z0-9-_]*)/ all classes. Example: var style = ".class1 { text-align: left; font-weight: bold} " + "/* --…
-
18
votes9
answers13997
viewsA: How to create a website without reloading every click on a link?
This can be done in many ways. You can use a script to submit requests by ajax by clicking links to the same domain on your site: (function() { var content = document.getElementById("div-id"), //…
-
1
votes2
answers238
viewsA: Redirecting of HTTP requests
Add to your . htaccess: <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^/?artigo/[023]$ /artigo/1 [R=302,L,QSA] </IfModule>…
-
1
votes5
answers7780
viewsA: How to use str_replace in single quotes without removing the ones that are required?
Use a regular expression to replace ' by " at the beginning and end of whole words: preg_replace_callback('/(?<=\s|\t|\r|\n| )(\'.+\')(?=\s|\t|\r|\n|\.|,| )/muU', function($match) { return '"' .…
-
8
votes4
answers2442
viewsA: In PHP how to calculate a random number?
The functions mt_rand() and Rand() generate numbers pseudo-random, the numbers generated by these functions are foreseeable. Alternatively you can make use of the function…
-
6
votes4
answers6297
viewsA: Form inserting twice in the bank (F5)
I suggest you use a token and redirect users to another page (302) after processing the form. This way the same data will not be sent multiple times when pressing F5. <?php…