-
Posts
291 -
Joined
-
Last visited
-
Days Won
1
Posts posted by mentalist
-
-
Not properly looked but why "$x<=25", that's only enough for the first set to be unique, not all three sets which are calc'd in the loop... I'd personally use a "while" loop probably...
Also the checks which get a second random are basically redundant since once passed them it regenerates another anyway at the begining of the loop!?!
-
Something like this...
... WHERE (IncidentDate BETWEEN '2014-09-01 14:00:00' AND '2014-12-31 23:59:59')
-
? Convert all the logo's to the same type, faster all round...
-
lol, PREG_SPLIT_DELIM_CAPTURE
$s="Dorothy lived in the midst of the great Kansas prairies, with Uncle Henry, who was a farmer, and Aunt Em, who was the farmer's wife"; $k = preg_split("/[\s]+|([,;:]+)/", $s,-1,PREG_SPLIT_DELIM_CAPTURE|PREG_SPLIT_NO_EMPTY); foreach($k as $e){ echo "_".$e."_<br />"; }
-
I have a sentence of say English litriture, i'm after splitting it into words, but the commas (and such, :, are to be treat as a word them selves, i.e. so I can know where they are. Full stops / periods can be ignore since previously split on them.
$keywords = preg_split("/[\s]+/", $content);
-
It could be more adaptive or even maybe written in a one liner, but here's my quick hack...
<?php // Simple CSS Parser // www.rawstar7.co.uk/site $fn="tmp/style.css"; $f = fopen($fn, "rb"); $contents = fread($f, filesize($fn)); fclose($f); $a=css_parse($contents); $out=css_print($a); function css_parse($s){ // STRIP OUT COMMENTS (Can be done elsewhere or missed out completely!) $s = preg_replace('!/\*.*?\*/!s', '', $s); $s = preg_replace('/\n\s*\n/', "\n", $s); // SPLIT BY "}" $a=explode("}",$s); $acss=array(); foreach($a as $e){ // SPLIT BY "{" $aa=explode("{",$e); // SPLIT NAMES LIST $anames=preg_split("/[\s,]+/", trim($aa[0])); // SPLIT TAGS LIST $atags=explode(";",$aa[1]); // SPLIT INDIVIDUAL TAGS INTWO K => V PAIRS // BUNDLE IT UP $acss[]=array($anames,$atags); } return $acss; } function css_print($a){ $sret= "<table>"; foreach($a as $e){ $sret.= "<tr><td>"; foreach($e[0] as $ee){ $sret.= $ee."<br />"; } $sret.= "</td><td>"; foreach($e[1] as $ee){ $sret.= $ee."<br />"; } $sret.= "</td></tr>\n"; } $sret.= "</table>"; return $sret; } ?> <html><head> <style> table,th,td { border: 1px solid #000; vertical-align: text-top; } </style> </head><body> <?php echo $out; ?> </body></html>
-
@requinix: The comments could be preparsed / stripped out.
@Jacques1: I'll have a crack at my own simplified css parser later More than what was needed for this hack but it'll serve useful...
-
Good point but any which way how does this scenario work with regex please?
Basicaaly capture anything from } to { (or start of file) prior to the match and working backwards.
-
Yup the first one would be an annoying anomaly, whereas in the second ".class1, .class2 "
So for now ignore the comments issue...
Any example on how to grab previous data would be great thanks
-
In this example i'm scanning a css file for colour hash codes...
$match='/(#[a-f0-9]{3,6})/is'; // matches colour hashes from 3 to 6 in length preg_match_all($match, $s, $a, PREG_PATTERN_ORDER);
That works ok for now, what i'm after is how once matched as above how to get some text from before the mmatch returned as a seperate group.Example css:
body {
background: #fff;
}
a {
color: #000;
text-decoration: none;
}
At the moment i'm just returned "#fff" and "#000", what i'm after is ("#fff","body") and ("#000","a"). So basically after match come back to before "{" and either to start of file or next "}".
Any help please?
-
If you do it clientside you have the overhead of always downloading the original large image
For that after thought I was thinking of uploads...?
-
-
@mentalis: I don't think that is what the instructions are asking for. you're describing the solution for data to flow across a row then create a new row after n records. What I am reading is that each row is a complete record with each column representing a different piece of data for that record.
...
Oops, assumed! Zatox, try that next
-
There's many ways to do it, could concatenate the arrays then do mod 4 on i and if i=4 add a tr, or as is write out to two strings then print at the end, use css divs and positioning, etc, etc...
-
Just for info's sake...
There may be a way using the HTML5 canvas, create it at a size then use canvas.scale(), there is a way to save this image ut can't remember it since never used it, only drawback is that it may have to be done clientside if that's acceptable?
-
Either make it bigger, i.e. 300dpi / 72 = 4.17, then scale w n h by 4.17, but that's probably unsatisfactory...
So, use ImageMagick instead of GD
http://php.net/manual/en/imagick.resampleimage.php
http://php.net/manual/en/imagick.setresolution.php
etc...
-
FYI there are many cheatsheets available for regulare expressions, here's first one I just found:
http://www.cheatography.com/davechild/cheat-sheets/regular-expressions/
-
user name : YOURDATABASE
You need to use username not database name...
-
Square brackets usually denote an OR list (set), so if you truely want it to start with "SPN" remove the square brackets...
-
Try instead:
if($submit!=FALSE){
The function mysql_query() returns FALSE on fail otherwise a resource (see http://php.net/manual/en/function.mysql-query.php)The other way would be:
if($submit){
-
I'm guessing that you're after S, P or N... not and!
Try using RLIKE instead: http://dev.mysql.com/doc/refman/5.0/en/regexp.html
Otherwise you'll need to explode the string and recreate a statement with OR's between... all within the LIKE
-
As said AVG will do it for you, however the maths is to add all the values together and then divide by how many values there were.
Here's a page on the three main types of average, the one you probably want is mean.
-
NB: Generally you'll find cokies in the Settings dialog.
-
You could do it in page by page like various registrations (say on dating sites), so they indicate the info for the new field, then the form is generated as required on the next page.
To do it in one page you would need to use Javascript and maybe Ajax.
Is that what you're after?
How to insert the dynamically created text box values to db in php ?
in PHP Coding Help
Posted