-
Posts
14,780 -
Joined
-
Last visited
-
Days Won
43
Everything posted by .josh
-
read the headers already sent sticky in this forum. You can use ob_start() as a bandaid or you could code properly and avoid having to bandaid to begin with.
-
If you don't know how to do it or where to look then how do you know whether or not it's a simple answer?
-
Assuming your file looks like this: Joe, 100, 5 Jane, 104, 5 Sam, 110, 6 Dick, 100, 5 etc... Use file to grab the list and put each line into an array element. Use a foreach loop to loop through each line. Inside the foreach loop, first trim the line. Then explode it. Next, make a new array where the key is a weight|height concated values from the exploded line, and the value of that array is the whole exploded line. This will effectively group all same weight|height lines together, into a multi-dim array. Next, use another foreach loop to loop through that list and make a new array of only the ones that have more than one name. You now have a multi-dim array of all names with same height and weight. So...you should end up with a structure like this: Array ( [0] => Array ( [0] => Array ( [0] => John [1] => 108 [2] => 5 ) [1] => Array ( [0] => Bob [1] => 108 [2] => 5 ) [2] => Array ( [0] => Rick [1] => 108 [2] => 5 ) ) [1] => Array ( [0] => Array ( [0] => Ray [1] => 110 [2] => 5 ) [1] => Array ( [0] => Mary [1] => 110 [2] => 5 ) ) ) As far as outputting the list to your format: Start with a foreach loop to go through each group of names. To get the number of people in that group, simply do a count($val) where $val is the variable you specified as the value in your foreach loop. You can use $val[1] and $val[2] for weight and height. For list of names, you would use another foreach loop nested inside the first one, to get each name from the inner arrays. Putting it into a comma separated list (as you showed in your post).
-
again, not really versed in xml, so maybe i'm talking out my ass, but are you by some chance using an existing xml list or whatever, and it can't create it because the element already exists, and adding something like 'e' to the front of it makes a new, unmade field (and therefore allows it to be created)?
-
the problem is that the session in $_session is not capitalized. It is case sensitive, needs to be $_SESSION.
-
if($_SESSION['all_in_na'] == 'yes') { // your variable equals 'yes' do something } if($_SESSION['all_in_na'] != 'yes') { // your variable does not equal 'yes' do something }
-
There's no reason why all of that can't be combined: $domain = "http://www.domain.com/"; $pattern = "~http://www\.~"; $replacement = ""; echo preg_replace($pattern, $replacement, $domain); And actually, if that is the extent of your $domain string (the only thing in it will be the url), you can just use substr, as it is much faster: $domain = "http://www.domain.com/"; echo substr($domain, 11);
-
You use normal html markup to make it bold, like so: $Message = "<b>First Name:</b> $firstName"; Or you can use <strong> tags or style it. Point is, you treat your email content just like outputting and formatting stuff on a web page. And as mentioned, in order to get something to show up bold in your email (or italicized, or any other markup), you have to specify html content in your email header.
-
\1 is the data captured from the first (..) match.
-
Are you sure you're looking in the right place for those returns? Using arrays as your parameters will return a multi-dim array.
-
there's nothing wrong with that code. Your error is somewhere else.
-
PHP Form Validation - mutually exclusive form fields
.josh replied to aeris7's topic in PHP Coding Help
Your code doesn't really account for which one to use. Which brings me to this question: Is this data being inserted into the same column, or do you have 2 columns, but one of them must be empty, the other one filled? -
post your new code
-
in case you didn't notice, what nrg_alpha did was add the i modifier after the delimiter. #blahblah#i which makes it case-insensitive.
-
going back to your OP, your condition isn't working because $QUESTIONS is a numeric array. You assign various posted values to it. Notice on your print_r how the keys are 0,1,2, etc...so when you do this: if ( $QUESTIONS['ch.$count'] == "Question" ) { You are checking for positions in your questions array using keys $QUESTIONS['ch1'], $QUESTIONS['ch2'] etc.. which are associative keys. You can mix keys in an array, but more to the point, those keys don't exist in your array. Remove the 'ch' from the mix.
-
I posted after your edit, so to respond to your edit: Right. There was never a bug or compatibility issue. ^ just behaves differently, depending on what modifier(s) you use. I suppose you could possibly argue that they should have made ^ stay the same no matter what, and have \A be the 'start of line' in multi-line mode. At face value, that does seem more consistent; I have no idea why it's not done like that. But I think it's stretching it to say it's some kind of bug that was fixed (or more accurately, bandaided).
-
<?php /* function to get all x,y coords of specified rgb color 4 arguments: path/to/image, and red, green, blue values of target pixel to search for. function assumes $pic to be a .jpg type image. You will have to change the code if you are using a different image type, or else setup some conditions to determine which image type $pic is, and use the proper GD functions for it. $r, $g, $b each takes a 0-255 dec format value. */ function getCoords ($pic, $r, $g, $b) { // put rgb args into array for comparison in loop $argrgb = array('red' => $r, 'green' => $g, 'blue' => $b); // create image resource of picture $image = imagecreatefromjpeg($pic); // get width and height of image list($width, $height) = getimagesize($pic); // loop through each column for ($y = 0; $y <= $height; $y++) { // loop through each pixel of the current row for ($x = 0; $x <= $width; $x++) { // get index of color at specific x,y coord $color_index = imagecolorat($image, $x, $y); // returns pixel color as array of red,green,blue,alpha $rgb = imagecolorsforindex($image, $color_index); // pop the alpha value off the end of the array array_pop($rgb); // compare pixel arrays. if they are the same, empty array is returned $result = array_diff($rgb, $argrgb); // if empty array is returned... if (empty($result)) // add the coordinate to our list $dotCoords[] = array('x' => $x, 'y' => $y); } // end $x } // end $y // return list of coords return $dotCoords; } // end getCoords /*** example ***/ // target picture $pic = "somepic.jpg"; // get all coords of pure white pixels $whiteCoords = getCoords($pic, 255, 255, 255); // output results echo "<pre>"; print_r($whiteCoords); echo "</pre>"; ?>
-
Even if perl has that restriction (which I don't know that it does, but I'm not an expert in perl), the preg_xx engine is pcre compatible, not pcre dependent. It is a separate engine that is modeled after the pcre engine, compiled in c and part of php's internal core. I looked around in the manual and sorry, I'm just not seeing any evidence to support your claims. so...as they say in the gaming world: screenshot or it didn't happen! In other words, you're going to have to pony up some links about that.
-
umm, are you sure about that? preg_xx functions are part of php. I don't think the regex engine makes system or platform calls in order to do its job... it should do the same thing regardless of what system php is running on.
-
haha whoops.
-
Assuming this: $dbconn = new dbConnection(); establishes a new database connection (like mysql_connect), I would suggest removing that from your recursive function. Not sure what dbConnection() looks like, but if you're not assigning the resource to a variable, that line + recursive function = opening up lots and lots of connections.