PHP - Merge 2 Gd Images With Alpha
I have 2 GD images, one is a JPG, the other is a gd created image.
Code: [Select] <?php header("content-type: image/png"); $img = imagecreatefromjpeg("./real/soldier.jpg"); $img2 = imagecreatetruecolor(300, 300); imagesavealpha($img2, true); $color = imagecolorallocatealpha($img2, 255, 0, 0, 75); imagefill($img2, 0, 0, $color); $final = imagecreatetruecolor(300, 300); imagecopymerge($final, $img, 0, 0, 0, 0, 300, 300, 100); imagecopymerge($final, $img2, 0, 0, 0, 0, 300, 300, 100); imagepng($final, null, 9); I am trying to place the gd created image (Red image) on top of the other (soldier.jpg), but for some reason I can not figure out why the red is a solid red when I told it to have transparency to it (75). So basically how do I create images like this with saved alpha? Similar TutorialsIm trying to use a cropping feature but when the image is cropped the alpha channel is lost. Anyone know where im going wrong here? if($ext == 'png') { $srcImg = imagecreatefrompng('avatars/'.$original); $newImg = imagecreatetruecolor($width, $height); imagealphablending($srcImg, true); imagesavealpha($srcImg, true); imagecopyresampled($newImg, $srcImg, 0, 0, $x1, $y1, $width, $height, $width, $height); imagepng($newImg, 'avatars/'.$user_name.'_avatar_cropped.png'); $link->query("UPDATE ".TBL_PREFIX."users SET u_avatar_cropped = '".$user_name."_avatar_cropped.png' WHERE u_username = '$user_name'") or die(print_link_error()); } Hi, I have a page that lists the names of the Artists in one column, and the title of their song in the next column. I've included a sort section that allows users to view the artist (with the corresponding title) that starts with whatever letter they press. I've now come to a point where I need to add in a check for numbers. (View attached image to understand what we're talking about) So if the artist name starts with any number between 0-9, it will be shown in order on the page once a user clicks on "#". I've tried doing it various ways, but can't seem to get it just right. Here is the code (I took out all my attempts to get the numeric sort working): <?php session_start(); include_once('inc/connect.php'); if (isset($_SESSION['username'])){ $loginstatus = "logout"; } else{ $loginstatus = "login"; } if(!isset($_SESSION['sort_counter'])) {$_SESSION['sort_counter'] = 1;} if(($_SESSION['sort_counter']%2) == 0){ //test even value $sortcount = "DESC"; }else{ //odd value $sortcount = ""; } $result = mysql_query("SELECT * FROM sheets ORDER BY artist"); $sheetscount = mysql_num_rows($result); $sortletteris = $_GET['letter']; $downloadclick = $_GET['downloadclick']; $show = $_GET['show']; $today = date("Y-m-d"); ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html lang="en-US" xml:lang="en-US" xmlns="http://www.w3.org/1999/xhtml"> <head> <link rel="stylesheet" type="text/css" href="styles/style.css" /> </head> <body bgcolor="#343331"> <!-- Header --> <div id="header"> <div id="headerleft"></div> <div id="headermiddle"><a href="index.php"><img src="img/logo.png"></a></div> <div id="headerright"> </div> </div> <!-- Content Top --> <div id="contenttop"> <div id="links"> <!-- 92x30 --> </div> </div> <!-- Content Middle --> <div id="contentmiddle"> <div id="content"> <div id="sort"> <?php echo "<center>".$sheetscount." Sheets Available<br />"; echo "<a href='newlyadded.php'>New Sheets</a><span> | </span><a href='request.php'>Request a Sheet</a></center>"; $letters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; echo "<center><div id='letters'>"; $i = 0; while ($i<26){ $sortletter = $letters[$i]; echo "<a href='index.php?letter=".$i."'>".$letters[$i]." </a>"; $i += 1; } echo " <a href='index.php'>All</a></div></center>"; if (($sortletteris)!=""){ // The letter that was clicked is set to this variable $mysortletter = $letters[$sortletteris]; //echo $mysortletter; // lname LIKE '$letter%' $result = mysql_query("SELECT * FROM sheets WHERE artist REGEXP '^[$mysortletter]' ORDER BY artist $sortcount"); $_SESSION['sort_counter'] = $_SESSION['sort_counter'] + 1; //increment after every run } elseif (($sortletteris)==""){ $result = mysql_query("SELECT * FROM sheets ORDER BY artist $sortcount"); $_SESSION['sort_counter'] = $_SESSION['sort_counter'] + 1; //increment after every run } $greenboxleft = "greenboxleft"; $greenboxright = "greenboxright"; $grayboxleft = "grayboxleft"; $grayboxright = "grayboxright"; $colorvalue = 0; echo "<br /><table width='600px' align='center' style='border-collapse:separate; border-spacing:0px;'><th style='background-color: #cccccc; border-bottom-style: solid; border-color: #6aa504;'>Artist</th><th style='background-color: #cccccc; border-bottom-style: solid; border-color: #6aa504;'>Title</th>"; while($row = mysql_fetch_array($result)) { if(($colorvalue%2)==0){ $styleleft = $greenboxleft; $styleright = $greenboxright; } else{ $styleleft = $grayboxleft; $styleright = $grayboxright; } echo "<tr>"; echo "<td align='center' width='250' id='$styleleft'><div id='songsboxleft'>". ucwords($row['artist']). "</div></td>"; echo "<td align='center' width='250' id='$styleright'><div id='songsboxright'><a target='_blank' name='downloadclick' href='".$row['url']."'>" .ucwords($row['title']). "</a></div></td>"; echo "</tr>"; $colorvalue++; } echo "</table>"; ?> </div> </div> </div> <!-- Content Bottom --> <div id="contentbottom"> </div> </body> </html> Hi, Im looking at using a statement like this to remove all text characters from a string. $outgoing = substr_replace($incoming,"",-1); The string is a currency that has a currency symbol in the beginning of the string, like "R500.00" I would like to remove the R, so it is just a numeric value... Please can you help me with any ideas on how to get this going? Been reading so much and its all confused me too badly. Regards, Chris This topic has been moved to Third Party PHP Scripts. http://www.phpfreaks.com/forums/index.php?topic=359102.0 In my .htaccess, I have the following to enter a domain name then a store number such as www.domain.com/c111
The page storeNumber.php displays perfectly call the correct variables through the _GET.
The help I got and has been set up works for an Alpha and thre rest numbers.
What would be rewriterule be to use any random string of Alpha Numberic characters? Such as C123, 12CF, cf15, C2f5...
RewriteOptions inherit RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^([a-z0-9-]+)$ /storeNumber.php?storeNumberID=$1 [NC,L]Thanks for any help in advance, Mike i want to preserve the numeric keys. When i print the array this is the result Code: [Select] Array ( [0] => one [1] => two [2] => three ) it should be Code: [Select] Array ( [0] => two [1] => one [2] => three ) Code: [Select] $test1[2] = "one"; $test2[1] = "two"; $test2[3] = "three"; $test = array_merge($test1,$test2); print_r($test); How do i solve this? How can I merge the array, but I keep in mind that I only need to merge userlocation and the usercity arrays. Current output... Code: [Select] Array ( [0] => Array ( [0] => userlocation [1] => 19 ) [1] => Array ( [0] => credentials [1] => ) [2] => Array ( [0] => specialties [1] => ) [3] => Array ( [0] => usercity [1] => place1 ) ) Desired output... Code: [Select] Array ( [0] => Array ( [0] => userlocation [1] => 19 [2] => usercity [3] => place1 ) [1] => Array ( [0] => credentials [1] => ) [2] => Array ( [0] => specialties [1] => ) ) How can this be done? The array is dynamic. i have this list of arrays Code: [Select] Array ( [0] => LeanBiz ) Array ( [0] => Boutique ) Array ( [0] => Feather ) Array ( [0] => Aggregate )i want to create one single array containing the values from x arrays. Hello, I've created a PHP file to merge XML files by ReferenceID(product_print_id) but i don't get the result that i want. I think i must use cloneNode and DOMNode::insertBefore but I think i'm lost. The first file is prodInfo.xml: <?xml version="1.0" encoding="utf-8"?> <PRODUCTINFORMATION> <PRODUCTS> <PRODUCT> <PRODUCT_NUMBER>53-03</PRODUCT_NUMBER> <PRODUCT_PRINT_ID>42</PRODUCT_PRINT_ID> <PRODUCT_NAME>ProductFirst</PRODUCT_NAME> <COLOR_CODE>03</COLOR_CODE> </PRODUCT> </PRODUCTS> </PRODUCTINFORMATION> and the second file is printInfo.xml: <?xml version="1.0" encoding="utf-8"?> <PRINTINGINFORMATION> <PRODUCTS> <PRODUCT> <PRODUCT_PRINT_ID>42</PRODUCT_PRINT_ID> <PRINTING_POSITIONS> <PRINTING_POSITION> <ID>TOP BOX</ID> <PRINTING_TECHNIQUE> <ID>DL</ID> </PRINTING_TECHNIQUE> <PRINTING_TECHNIQUE> <ID>L2</ID> </PRINTING_TECHNIQUE> <PRINTING_TECHNIQUE> <ID>P4</ID> </PRINTING_TECHNIQUE> </PRINTING_POSITION> </PRINTING_POSITIONS> </PRODUCT> </PRODUCTS> </PRINTINGINFORMATION> The php file i created is the following: <?php header ("Content-Type:text/xml"); $target = new DOMDocument(); $target->preserveWhiteSpace = FALSE; $target->load('prodInfo.xml'); $targetXpath = new DOMXpath($target); $source = new DOMDocument(); $source->load('printInfo.xml'); $sourceXpath = new DOMXpath($source); foreach ($targetXpath->evaluate('//PRODUCT') as $PRODUCTNode) { $PRODUCT_PRINT_ID = $targetXpath->evaluate('string(PRODUCT_PRINT_ID)', $PRODUCTNode); foreach ($sourceXpath->evaluate('//PRODUCT[PRODUCT_PRINT_ID="'.$PRODUCT_PRINT_ID.'"]/*[not(self::PRODUCT_PRINT_ID)]') as $node) { $PRODUCTNode->appendChild( $target->importNode($node, TRUE) ); } } $target->formatOutput = TRUE; echo $target->saveXml(); ?> The output/result i get is this: <?xml version="1.0" encoding="utf-8"?> <PRODUCTINFORMATION> <PRODUCTS> <PRODUCT> <PRODUCT_NUMBER>53-03</PRODUCT_NUMBER> <PRODUCT_PRINT_ID>42</PRODUCT_PRINT_ID> <PRODUCT_NAME>ProductFirst</PRODUCT_NAME> <COLOR_CODE>03</COLOR_CODE> <PRINTING_POSITIONS> <PRINTING_POSITION> <ID>TOP BOX</ID> <PRINTING_TECHNIQUE> <ID>DL</ID> </PRINTING_TECHNIQUE> <PRINTING_TECHNIQUE> <ID>L2</ID> </PRINTING_TECHNIQUE> <PRINTING_TECHNIQUE> <ID>P4</ID> </PRINTING_TECHNIQUE> </PRINTING_POSITION> </PRINTING_POSITIONS> </PRODUCT> </PRODUCTS> </PRODUCTINFORMATION> But what i want to achieve is this: <?xml version="1.0" encoding="utf-8"?> <PRODUCTINFORMATION> <PRODUCTS> <PRODUCT> <PRODUCT_NUMBER>53-03</PRODUCT_NUMBER> <PRODUCT_PRINT_ID>42</PRODUCT_PRINT_ID> <PRODUCT_NAME>ProductFirst</PRODUCT_NAME> <PRINTING_POSITIONS> <PRINTING_POSITION> <ID>TOP BOX</ID> <PRINTING_TECHNIQUE> <ID>DL</ID> </PRINTING_TECHNIQUE> <COLOR_CODE>03</COLOR_CODE> </PRINTING_POSITION> <PRINTING_POSITION> <ID>TOP BOX</ID> <PRINTING_TECHNIQUE> <ID>L2</ID> </PRINTING_TECHNIQUE> <COLOR_CODE>03</COLOR_CODE> </PRINTING_POSITION> <PRINTING_POSITION> <ID>TOP BOX</ID> <PRINTING_TECHNIQUE> <ID>P4</ID> </PRINTING_TECHNIQUE> <COLOR_CODE>03</COLOR_CODE> </PRINTING_POSITION> </PRINTING_POSITIONS> </PRODUCT> </PRODUCTS> </PRODUCTINFORMATION> So as you can see i want to repeat the field PRINTING POSITION ID for every PRINTING TECHNIQUE and also i want to repeat the field COLOR CODE for every PRINTING POSITION. Anyone can help me with this? Thanks in advance. Hi, I'm trying to make my game navigation that involves switching div images to navigate in the game world. It is browser based. The first script, the user clicks on the world map to go to "Teardrop Ocean". The second script lets the user press the "further" button or "back" button to navigate within "Teardrop Ocean". My problem is I'm trying to combine the image map navigation with the "further" and "back" navigation. The problem is, I don't know if it's possible since the first world map script involves javascript. Here is the code, any help greatly appreciated Thanks. Derek This is the code that uses javascript to process a hidden form to use php to output. This is our "world map" link, that should load the "teardrop ocean" image inside the div, which it doesn't do yet here. Code: [Select] <?php $zone=''; if(isset($_POST['checker']) && $_POST['checker'] == 'checked') { echo "it worked !"; $zone="<img src='teardrop.jpg'/>"; } if(isset($_POST['back'])) { $zone=''; } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <body> <form action="aradia.php" method="post" name="mapform" id="mapform"> <input type="hidden" name="checker" value="checked" /> <div align="left"> <img src="aradia.jpg" width="256" height="328" border="0" usemap="#Map" /></div> </form> <map name="Map" id="Map"> <area shape="rect" coords="5,176,81,249" href="javascript: void(0);" onclick="javascript: document.getElementById('mapform').submit();" /> </map> <div align="center"><?php echo $zone;?></div> <form action="aradia.php" method="post" > <input type = "submit" name="back" value="back" /></form> </body> </html> and here is the "Teardrop ocean" navigation, which uses php to navigate forward and backwards in the zone, but can't go back to the world map, or there is no way to yet. Code: [Select] /////////////////////////////GAME NAVIGATION AND MONSTER SEARCH CODE NOT FINISHED////////////////////////////////// if(( !isset($_SESSION['current_background']) && !isset($_SESSION['currentMonster'])) OR (! $_POST)) { $_SESSION['current_monster'] = 0; $_SESSION['current_background'] = 0; } if (!isset($_SESSION['background']) && !isset($_SESSION['monster'])) { $_SESSION['background'] = array ( "<img src='sundragon_environments/ocean/ocean1_FRAME.jpg'/>", "<img src='sundragon_environments/ocean/ocean1_FRAME2.jpg'/>", "<img src='sundragon_environments/ocean/ocean1_FRAME3.jpg'/>", "<img src='sundragon_environments/ocean/ocean1_FRAME4.jpg'/>", "<img src='sundragon_environments/ocean/ocean1_FRAME5.jpg'/>" ); $_SESSION['monster'] = array ( "<img src='sundragon_monsters_source/water/goldfish/goldfish.png'/>", "<img src='sundragon_monsters_source/water/eel/eel_transp_FRAME.png '/>", "<img src='sundragon_monsters_source/water/shark/shark_transp_FRAME.png'/>", "<img src='sundragon_monsters_source/water/octalisk/octalisk_transp_FRAME.png'/>", "<img src='sundragon_monsters_source/water/teardrop_ocean_protector/teardrop_ocean_protector.png'/>" ); } if(!isset($_SESSION['current_background']) && !isset($_SESSION['current_monster'])) { $_SESSION['current_monster']=0; $_SESSION['current_background'] = 0; } if(isset($_POST['further'])) { $_SESSION['current_monster'] = isset($_SESSION['monster'][$_SESSION['current_monster'] + 1]) ? ($_SESSION['current_monster'] + 1) : 0; $_SESSION['current_background'] = isset($_SESSION['background'][$_SESSION['current_background'] + 1]) ? ($_SESSION['current_background'] + 1) : 0; } elseif(isset($_POST['back'])) { $_SESSION['current_monster'] = isset($_SESSION['monster'][$_SESSION['current_monster'] - 1]) ? ($_SESSION['current_monster'] - 1) : count($_SESSION['monster'])-1; $_SESSION['current_background'] = isset($_SESSION['background'][$_SESSION['current_background'] - 1]) ? ($_SESSION['current_background'] - 1) : count($_SESSION['background'])-1; } $currentBackground=$_SESSION['background'][$_SESSION['current_background']]; $currentMonster=$_SESSION['monster'][$_SESSION['current_monster']]; and I echo out $currentBackground and $currentMonster in the main game div. I have loaded two similar xml files by simplexml_load_file, and I want to merge them. They have similar structure and I want to put them into a single xml. As a matter of fact, I have parse two similar xml files with foreach, and now I want to put them together and use one foreach for the merged xml. I hope to find a function like array_merge() Whats the array function to merge two or more similar patterns in a single array. $a = array('red','pink','red','green','blue'); Basically i need to combine "red" so the output will be red, pink, green, blue I'm using a upload class that works with $_FILES, but have a couple of reasons to need the content of php://input: 1) When submitting PDF forms as a complete form, the form is available in php://input. 2) An ajax uploader I'd like to use submits the file making it only available in php://input. I know I could use an if statement to check $_FILES else php://input, but I'm concerned about security, and being able to identify the filetype, get the size, etc. I'm skipping over some other details, because I need to leave in 5 minutes. I've not seen any classes that merge the two ( $_FILES and php://input ), and really haven't seen any that are specifically for php://input. Can anyone offer advice or point me in the right direction? I'd like to merge the following function into my main download page but can't figure out how to do it. I've modified the main download page to do the actual downloads but how to manage making the database entries for each download is the problem. I guess I could use a case statement at the end of download.php to set $l_filename then run the pdo sql code. mydownloader.php - Currently located in download directory <?php $php_scripts = '../../php/'; require $php_scripts . 'PDO_Connection_Select.php'; require $php_scripts . 'GetUserIpAddr.php'; function mydloader($l_filename=NULL) { $ip = GetUserIpAddr(); if (!$pdo = PDOConnect("foxclone_data")) { exit; } */ if( isset( $l_filename ) ) { header('Content-Type: octet-stream'); header("Content-Disposition: attachment; filename={$l_filename}"); header('Pragma: no-cache'); header('Expires: 0'); readfile($l_filename); /* $ext = pathinfo($l_filename, PATHINFO_EXTENSION); $stmt = $pdo->prepare("INSERT INTO download (address, filename,ip_address) VALUES (?, ?, inet_aton('$ip'))"); $stmt->execute([$ip, $ext]) ; $test = $pdo->query("SELECT lookup.id FROM lookup WHERE inet_aton('$ip') >= lookup.ipstart AND inet_aton('$ip') <= lookup.ipend"); $ref = $test->fetchColumn(); $ref = intval($ref); $stmt = $pdo->prepare("UPDATE download SET lookup_id = '$ref' WHERE address = '$ip'"); $stmt->execute() ; } else { echo "isset failed"; } } mydloader($_GET["f"]); exit;
<?PHP require_once("header.php"); ?> </head> <body> <?PHP require_once("navbar.php"); ?> <!--==================================================================== Download =======================================================================--> <?php $php_scripts = '../php/'; require $php_scripts . 'PDO_Connection_Select.php'; if (!$pdo = PDOConnect("foxclone_data")) { exit; } $test = $pdo->query("SELECT filename FROM files WHERE id =1"); $isoname = $test->fetchColumn(); $test = $pdo->query("SELECT md5 FROM files WHERE id =1"); $md5file = $test->fetchColumn(); $test = $pdo->query("SELECT filename FROM files WHERE id =2"); $pdfname = $test->fetchColumn(); $test = $pdo->query("SELECT filename FROM files WHERE id =3"); $debname = $test->fetchColumn(); $test = $pdo->query("SELECT md5 FROM files WHERE id =3"); $debmd5 = $test->fetchColumn(); $test = $pdo->query("SELECT filename FROM files WHERE id =4"); $srcname = $test->fetchColumn(); $test = $pdo->query("SELECT md5 FROM files WHERE id =4"); $srcmd5 = $test->fetchColumn(); $test = $pdo->query("SELECT filename FROM files WHERE id =5"); $debfile = $test->fetchColumn(); ?> <div class="head__h1">FoxClone Download Page</div> <div class ="download"> <div class="down__row"> <div class="down__column" style="background-color:#ddd;"> <div class="part__head">Get the "<?php echo "{$isoname}";?>" file (approx. 660MB)</div><br> <a href="download/{$isoname}";?>"><center><img src="images/download.png" style="height:44px; width:144px;" alt="download iso"> </center></a> <br /> <div class="part__head">The MD5sum is: <?php echo "{$md5file}";?> </div> <br/> <hr> <div class="part__head">Read or Download the Installation and Use Instructions </div><br> <a href="<?php echo "download/{$pdfname}";?>"><center><img src="images/download.png" style="height:44px; width:144px;" alt="download manual"></center></a><br> <hr> <div class="part__head">How To Install To A USB/CD</div> <div class="down__text">1. Download the iso file <br /> 2.<span class="tab">a. If burning to a USB stick use the USB image writer that comes with your distribution. </span> <br /> <span class="tab3">b. If burning to a CD, there are many Linux utilities, xfburn is one of the simplest. Install from your software manager/centre if not installed.</span> </div> <hr> <div class="part__head">How To Boot The USB/CD</div> <div class="down__text">At the manufacturer’s splash screen, press the key to get into the boot menu. This key varies across PCs, as an example for a Lenovo Thinkpad it is F12. Consult your user manual to find out what the key is or google. Do not confuse the boot menu with the boot priority order settings in BIOS. The boot menu is a one time selection for the device to use to boot the PC. It overrides the normal boot priority order. The next time you boot, the PC will revert to the normal boot order. Virtually all BIOSs support this feature, they just do it differently. </div> </div> <div class="down__column" style="background-color:#ddd;"> <div class="part__head">Get the "<?php echo "{$debname}";?>" file (approx. 7MB) </div><br> <a href="download/{$debname}";?>"><center><img src="images/download.png" style="height:44px; width:144px;" alt="download deb file"> </center></center></a> <br /> <div class="part__head">The MD5sum is: <?php echo "{$debmd5}";?> </div> <div class="down__redtext"><br>WARNING - FOR EXPERT USE ONLY !!!</div> <div class="down__text"><br>This .deb file is designed to be installed on a large USB drive, typically 1TB or greater, that already has an operating system installed and is intended as a backup drive.<b> For more information <a href="/download/deb_file.pdf" style="color:#ff0099">Click Here.</a></b></h3> </div> <hr> <div class="part__head">Get the "<?php echo "{$srcname}";?>" Source file (approx. 6MB) </div><br> <a href="download/{$srcname}";?>"><center><img src="images/download.png" style="height:44px; width:144px;" alt=""></center> </a> <br> <div class="part__head">The MD5sum is: <?php echo "{$srcmd5}";?> </div> <div class="down__text"><br />This contains the files used to build Foxclone itself. It is provided to meet the terms of the GNU General Public License.</div> </div> </div> </div> <?PHP require_once("footer.php"); ?>
I have two arrays, as follows: $array1 = (1, 2, 3); $array2 = (4, 5, 6); Is there a function to combine the two without having to do a loop? I'd like to create: $array3 = (1, 2, 3, 4, 5, 6); I have a task that seems to be complex.
Short Description: currently users of the application I am hired to develop have two steps to do when using the app:
1. Select a Product Line (A, B, C, D)
2. Select input parameters for that product line - all product lines have simlar "Main" input parameters, but also each line has its own special features that can be selected.
3. Selections for that product line are shown - the result is a long table or options for that particular product line. Things like price, discounts, product specifications, etc.
What the users want now is this:
1. Select input parameters (not sure how to handle individual product lines special parameters yet)
2. Selections for all product lines are shown
The code base is legacy code, with code thrown around everywhere. One idea me and my coworkers have been considering is a complete rewrite, since it will help us with writing tighter code, and do what the customer wants. But that will also take time, and there is no spec. The spec is in the code mess.
Another one is I am considering now is a "merge". Somehow merge the product lines, since we have the separate product modules (A, B, C, D), there must be a way to consider maybe extending one to include the others, or somehow get me to the end result -- allow users to see selections for all product lines.
Do you have any experience, any suggestions on how to do this? I know this needs details, and details are in my code that you don't see, and most likely won't have the time to read and understand anyway.
But I am looking for any ideas or encouragement though that may help. And my question is -- is there any kind of procedure or technique or something to deal with the problem I am facing -- merging several separate yet similar modules into one single merged module. How do I approach this, what are some things that could help, etc. That's what I'm looking for.
Hi, Have a question regarding array handling / changes. I have the below posted array. I need to consolidation the "categoryId" & "categoryName" where the "id" have the same value e.g. 66, then remove the duplicates but keep the merged data. The new merged data could be stored under a key e.g. [categories] => Array ( [categoryId] = 28 [categoryName] = Game Drive [1] [categoryId] = 29 [categoryName] = Game Drive etc. Code: [Select] Array ( [0] => Array ( [id] => 66 [name] => Person Name [description] => Test Desc [webUrl] => www.nish.co.za [emailAddress] => abc@abc.co.za [telNumber] => 123123 [provinceId] => 3 [cityId] => 2 [creationDate] => 2010-09-27 17:42:55 [activated] => Y [categoryId] => 28 [provinceName] => Gauteng [cityName] => Johannesburg [categoryName] => Game Drives ) [1] => Array ( [id] => 66 [name] => Person Name [description] => Test Desc [webUrl] => www.nish.co.za [emailAddress] => abc@abc.co.za [telNumber] => 123123 [provinceId] => 3 [cityId] => 2 [creationDate] => 2010-09-27 17:42:55 [activated] => Y [categoryId] => 29 [provinceName] => Gauteng [cityName] => Johannesburg [categoryName] => Nature Reserve ) [2] => Array ( [id] => 66 [name] => Person Name [description] => Test Desc [webUrl] => www.nish.co.za [emailAddress] => abc@abc.co.za [telNumber] => 123123 [provinceId] => 3 [cityId] => 2 [creationDate] => 2010-09-27 17:42:55 [activated] => Y [categoryId] => 34 [provinceName] => Gauteng [cityName] => Johannesburg [categoryName] => Rehabilitation Centre ) [3] => Array ( [id] => 65 [name] => Person Name [description] => This is the true test [webUrl] => http://www.klil.com [emailAddress] => abc@abc.co.za [telNumber] => 12311231 [provinceId] => 3 [cityId] => 2 [creationDate] => 2010-09-26 19:33:14 [activated] => Y [categoryId] => 28 [provinceName] => Gauteng [cityName] => Johannesburg [categoryName] => Game Drives ) [4] => Array ( [id] => 65 [name] => Test Multiple Categ [description] => This is the true test [webUrl] => http://www.klil.com [emailAddress] => abc@abc.co.za [telNumber] => 12311231 [provinceId] => 3 [cityId] => 2 [creationDate] => 2010-09-26 19:33:14 [activated] => Y [categoryId] => 29 [provinceName] => Gauteng [cityName] => Johannesburg [categoryName] => Nature Reserve ) [5] => Array ( [id] => 65 [name] => Person Name [description] => Description Text [webUrl] => http://www.test.com [emailAddress] => abc@abc.co.za [telNumber] => 12311231 [provinceId] => 3 [cityId] => 2 [creationDate] => 2010-09-26 19:33:14 [activated] => Y [categoryId] => 34 [provinceName] => Gauteng [cityName] => Johannesburg [categoryName] => Rehabilitation Centre ) [6] => Array ( [id] => 64 [name] => Person Name [description] => Description Text [webUrl] => www.tree.com [emailAddress] => abc@abc.co.za [telNumber] => 1123123123 [provinceId] => 3 [cityId] => 1 [creationDate] => 2010-09-26 12:10:56 [activated] => Y [categoryId] => 28 [provinceName] => Gauteng [cityName] => Alexandra [categoryName] => Nature Walks ) [7] => Array ( [id] => 64 [name] => Person Name [description] => Description Text [webUrl] => www.tree.com [emailAddress] => abc@abc.co.za [telNumber] => 1123123123 [provinceId] => 3 [cityId] => 1 [creationDate] => 2010-09-26 12:10:56 [activated] => Y [categoryId] => 29 [provinceName] => Gauteng [cityName] => Alexandra [categoryName] => Nature Reserve ) [8] => Array ( [id] => 64 [name] => Person Name [description] => Description Text [webUrl] => www.tree.com [emailAddress] => abc@abc.co.za [telNumber] => 1123123123 [provinceId] => 3 [cityId] => 1 [creationDate] => 2010-09-26 12:10:56 [activated] => Y [categoryId] => 34 [provinceName] => Gauteng [cityName] => Alexandra [categoryName] => Rehabilitation Centre ) [9] => Array ( [id] => 63 [name] => Person Name [description] => Description Text [webUrl] => www.test.com [emailAddress] => abc@abc.co.za [telNumber] => 123123 [provinceId] => 5 [cityId] => 3 [creationDate] => 2010-09-26 09:58:41 [activated] => Y [categoryId] => 29 [provinceName] => Limpopo [cityName] => Bandelierkop [categoryName] => Nature Reserve ) ) Thanks in advance, Peter For example: class People{ var $them = array(); function groupPeople(){ foreach($this->them as $him){ echo $him.", "; } } } $people = new People; $people->them = array('Harry','Todd'); $people->them = array('Tom','Jerry'); $people->groupPeople(); // result: Tom, Jerry, I think this code is working. However, I need to merge those array above, array('Harry','Todd') and array('Tom','Jerry') So I can get array('Harry','Todd','Tom','Jerry') and a list of names as a result. Maybe I should use array_merge, but how? A little help would be appreciated. Thank you in advanced, ayok I am using pieces of an array like this: $data['0']; $data['2']; $data['3']; and so on...I think up to around $data['70']; I need to take the values of $data['29'] through $data['64'] and combine them. (stumped) On top of that I have to comma separate those now combined values (stumped). Actuall Code: $handle = fopen("test.csv", "r"); while (($data = fgetcsv($handle, 5000, ",")) !== FALSE){ $needed = $data['29'] .", ". $data['30'] .", ".$data['31']; // ALL THE WAY TO $data['65'] } I know how to do it the long way, could someone help me shorten my work? Thank you for your help. |