Jump to content

matthewtbaker

Members
  • Posts

    44
  • Joined

  • Last visited

About matthewtbaker

  • Birthday 11/20/1983

Profile Information

  • Gender
    Male
  • Location
    Bournemouth, UK

matthewtbaker's Achievements

Newbie

Newbie (1/5)

3

Reputation

  1. But changing an array to null for instance isn't the same as unset, is it? $array=null;
  2. Just a thought... Is it possible to unset a global variable/array from within a function? So basically I want to pass an array to a function to convert to a string then destroy the original array. I'd like to keep it all contained within the function to reduce any additional clear-up scripting required. Here's my example code below: $GLOBALARRAY = array("keyname1" => "value1", "keyname2" => "value2"); $newstring = convertArrayToString($GLOBALARRAY, true); function convertArrayToString($array, $unset = false) { $string = ''; //Loop for each array value foreach ($array as $key => $value) { $string = $string . $key . '=' . $value ';'; } if ($unset === true) { unset($GLOBALARRAY_WHICH_WAS_PASSED); } return $string; } My guess is that I need to either get the name of the passed array or pass by reference? Thanks for your thoughts. Matt
  3. Just for the record; I simplied the code using a foreach loop. foreach ($BigArray as $key => $aBigArrayValue) { foreach ($aSmallArray as $sSmallValue) { } }
  4. You're welcome cleeclee, feel free to give my post a 'like point'. lol. It's difficult to get started but once you do... it only gets worse. Good luck!
  5. Basing my approach on Muddy_Funster I came up with the below which successfully resolves the original question. I thought I would share it in case anyone comes across this post in the future. for ($iBigArrayIndex = 0; $iBigArrayIndex < sizeof($iBigArrayIndex); $iBigArrayIndex++) { for ($iSmallArrayIndex = 0; $iSmallArrayIndex < sizeof($SmallArray); $iSmallArrayIndex++) { if ($SmallArray[$iSmallArrayIndex]['url'] == $BigArray[$iBigArrayIndex]['url']) { $BigArray[$iBigArrayIndex]['referrer'] = $BigArray[$iBigArrayIndex]['referrer'] . ',' . $SmallArray[$iSmallArrayIndex]['referrer']; } else { $BigArray[] = array('url' => $SmallArray[$iSmallArrayIndex]['url'], 'referrer' => $SmallArray[$iSmallArrayIndex]['referrer']); } } } I was surprised that there was not a standard PHP function that does this. Does anyone have a neater/cleaner way of doing this? Matt
  6. Hi pbs, From what I can work out the array_intersect() function does not seem to support multidimensional arrays. It also does not merge values depending on whether a specified key matches or not.
  7. Thanks Silkfire worked like a charm. I will try your shorter approach salathe, thank you.
  8. Thanks Jessica, these are however as a string is passed from a curl function run earlier. This function simply strips out the header or the body for seperate anaylsis.
  9. margin: 0 auto; is the answer. You do seem to have a lot of: Used within your layout. Perhaps consider a different method which is friendly for mobile browsers.
  10. Perhaps mark this topic as solved?
  11. cleeclee: When creating a basic HTML file you must only ever have one HTML declaration, one head declaration and one body declaration. Having anymore will not only make the code very difficult to maintain it can cause issues when the browser renders the page. Use the below as your basic template: <!doctype html> <html> <head> <title>Page Title</title> <link rel="stylesheet" href="style.css" /> <script src="functions.js"></script> </head> <body> <h1>Page Title</h1> <p>Paragraph</p> </body> </html> Once you have your template built then proceed to insert your swf references. If you wish to insert them into a DIV ensure you only use the a div ID once. Alternatively you can use classes. <div id="flashContent1"></div><div id="flashContent2"></div> or <div class="flashContent"></div><div class="flashContent"></div> Now you should be able to paste what ever object you like within the <div>as long as their IDs are unique. <div class="flashContent"> <object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="372" height="217" id="airflowgraph" align="middle"> <param name="movie" value="airflowgraph.swf" /> <param name="quality" value="high" /> <param name="bgcolor" value="#000000" /> <param name="play" value="true" /> <param name="loop" value="true" /> <param name="wmode" value="window" /> <param name="scale" value="showall" /> <param name="menu" value="true" /> <param name="devicefont" value="false" /> <param name="salign" value="" /> <param name="allowScriptAccess" value="sameDomain" /> <!--[if !IE]>--> <object type="application/x-shockwave-flash" data="airflowgraph.swf" width="372" height="217"> <param name="movie" value="airflowgraph.swf" /> <param name="quality" value="high" /> <param name="bgcolor" value="#000000" /> <param name="play" value="true" /> <param name="loop" value="true" /> <param name="wmode" value="window" /> <param name="scale" value="showall" /> <param name="menu" value="true" /> <param name="devicefont" value="false" /> <param name="salign" value="" /> <param name="allowScriptAccess" value="sameDomain" /> <!--<![endif]--> <a href="http://www.adobe.com/go/getflash"> <img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" /> </a> </object> </div> I hope this helps. Matt
  12. Hi phpfreak-ers, $BigArray[] = array('url' => 'www.example.com', 'referer' => 'refer1'); $BigArray[] = array('url' => 'www.demo.com', 'referer' => 'refer1'); $SmallArray[] = array('url' => 'www.example.com', 'referer' => 'refer2'); Basically I want to compare the two example arrays (above) and if a duplicate 'url' is found then I'd like to merge the 'referer' values in $BigArray otherwise add as an additional record. So I should be left with: Not syntax just used to explain my objective $BigArray url='www.example.com', 'referer' = 'refer1refer2'. $BigArray url='www.demo.com', 'referer' = 'refer1'. I've tried a day and a half worth of approaches and can't get it working. Thanks for your help in advance! Matt
  13. Hi, I'm building a function and was wondering if there's a method to present options to the developer when calling it. For instance I have a function which can return either HTTP Header Reponse Code, Full HTTP Header or HTML Body. When declaring the function I have function Return_Web_Content($url, $returnwhat) { switch ($returnwhat) case 'HTTP Header' : return $header; break; and so on... } So when calling the function during coding is there a way for have the options 'HTTP Header Response Code, Full HTTP Header and HTML Body presented instead of just writing the values into a string? Many thanks Matt
  14. Good day! I've tried a few routes but haven't managed a simple approach. Ideally I'd like to use one of PHPs built in functions to make the code cleaner and easier to follow. Basically I need to remove anything after a defined number of occurrences of a character from the example string below; $iLevels = 2; $sUrl = http://www.example.com/products/entertainment/films/dvd/page.html So in this case I need to remove anything after the second to last forward slash, deleting dvd/page.html. The number of forward slashes to remove is variable therefore a flexible solution is needed. Thanks for your help/advice in advance! Matt
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.