Jump to content

DocM3

New Members
  • Posts

    9
  • Joined

  • Last visited

    Never

Everything posted by DocM3

  1. ty! I'll test it tomoz! I'll let you know if it works
  2. argh...ofc; // Given URL's $data = explode("\n", $_POST['arenaVanURLs']); //strip HTTP:// foreach ($data as $row) { if (strncasecmp($row, "http://", 7) == 0) { $row = substr($row, 7); $urls[] = $row; } else { $urls[] = $row; } } // here i've got $urls with all the URLs in an array //which data to retrieve? $cols = calculateBitFlag(array( "title", "url", "external links", "links", "mozrank", "subdomain mozrank", "status code", "domain authority", "page authority")); $data = urlMetrics($urls,$cols); // this is the point where some of the urls are missing and an array gives some blank values, // so i figured to check if an URL is present, if not add some data. For testing purpose my name, but preferable the URL that was there.. only problem is i don't know how to get it there from the previous array $urls: foreach ($data as $k) { if (empty($k['uu'])) { $k['uu'] = "Michel"; } echo "<pre>"; echo $k['uu']; //outputs every URL, and if empty shows "Michel" echo "</pre>"; } echo "<pre>"; print_r($urls); // outputs all the URLs that were in the POST print_r($data); // outputs the arrays with data but without correct URL echo "</pre>"; echo "<br/>";
  3. Hello My case: I´ve got an array with URL´s. These URL's go into a fancy function to return data about the URL. Including the URL i requested data from. But when there is not data available i get an empty string back. The problem here is that i cannot display which URL has no data because the URL is lost. I do however know the position within the array. This is always the same as the place in the original array. Example I parse 4 URL's. The first URL is returning blank. URLS that were parsed: Array ( [0] => www.google.com [1] => www.url.com/some/long/url [2] => www.different.com/url/in/long_tail.html [3] => www.phpfreaks.com/adhasdf/dasfasoidf/d ) result: Array ( [0] => Array ( [fmrp] => 5.147762749931316 [fmrr] => 5.86720935495745e-08 [pda] => 48.61641496109651 [ueid] => 0 [uid] => 0 [umrp] => 0 [umrr] => 0 [upa] => 1 [us] => 0 [ut] => [uu] => ) [1] => Array ( [fmrp] => 5.147762749931316 [fmrr] => 5.86720935495745e-08 [pda] => 48.61641496109651 [ueid] => 136 [uid] => 174 [umrp] => 4.077553799180208 [umrr] => 6.547280352698674e-11 [upa] => 38.83549859356688 [us] => 200 [ut] => TITLE C [uu] => www.url.com/some/long/url ) [2] => Array ( [fmrp] => 5.147762749931316 [fmrr] => 5.86720935495745e-08 [pda] => 48.61641496109651 [ueid] => 3 [uid] => 31 [umrp] => 4.135396571638388 [umrr] => 7.716335744351054e-11 [upa] => 30.18026636416376 [us] => 200 [ut] => TITLE B [uu] => www.different.com/url/in/long_tail.html ) [3] => Array ( [fmrp] => 5.147762749931316 [fmrr] => 5.86720935495745e-08 [pda] => 48.61641496109651 [ueid] => 0 [uid] => 23 [umrp] => 3.959295614825166 [umrr] => 4.679367784084114e-11 [upa] => 21.93576871626221 [us] => 0 [ut] => [uu] => www.phpfreaks.com/adhasdf/dasfasoidf/d ) so now i want ww.google.com displayed in array[0][uu].. i just can't get it done. My thoughts here: check every array if the ['uu'] got turned back empty. If so, place in the url of the corresponding number there. I just can't magage it and therefore requesting your thougts/help. Thanks in advance!
  4. Helloa, I'm just new here, but i would like to suggest implementing some sort of like button. i/e I wanted to like/thank requinox for his last answer in my topic. It wass unnecessary to formulate an answer, but a like/thank you button would supply to let the requinox know it's been read/thanked! Other peepz 'listening' the post could let the posters know their answer reached them too by liking the post/topic too. You could even go as far as creating some sort of ranking factor on who has the most appreciated posts like this
  5. He Requinix! After some puzzeling it is finally working! Have run over your explanation a couple of times. Did some more googling/thinking and shabam! a magic word missing here was the multidimensional array. Seems like what i'm using here is a multidimensional array with associative arrays within. Thank you v/m, i will be back! ps. how do you get those awesome colors inside your code here? using [ code -] won't do that
  6. i'm sorry but i don't understand exactly. What i think you are saying: Stop working with associative arrays within an array and change this: $universiteiten = array( "uniAmsterdamVan" => array('uniNaam' =>'Universiteit van Amsterdam', 'uniID' => 'uva'), "uniAmsterdamVrij" => array('uniNaam' =>'Vrije Universiteit Amsterdam', 'uniID' => 'vu'), into multiple instances of $universiteit, like this: $universiteiten["uniAmsterdamVan"]["uva"]["http://#"]; $universiteiten["uniAmsterdamVrij"]["vu"]["http://#"]; i'm trying to understand here
  7. hmz.. Here's all of it: // Functies inladen include_once('INCLUDES/functions.php'); // Hodex XML bestanden in array stoppen // Bevat hodex URL's van alle scholen en school afkortingen $hodexDirectory = get_xml_feed('coolfeed.xml'); ///////////start////////////// ///Variabelen declareren/// ///////////////////////////// /// De Universiteiten $universiteiten = array( $uniAmsterdamVan = array('uniNaam' =>'Universiteit van Amsterdam', 'uniID' => 'uva'), $uniAmsterdamVrij = array('uniNaam' =>'Vrije Universiteit Amsterdam', 'uniID' => 'vu'), $uniDelft = array('uniNaam' =>'Technische Universiteit Delft', 'uniID' => 'tud'), $uniEindhoven = array('uniNaam' =>'Techische Universiteit Eindhoven', 'uniID' => 'tue'), $uniGroningen = array('uniNaam' =>'RijksUniversiteit Groningen', 'uniID' => 'rug'), $uniLeiden = array('uniNaam' =>'Universiteit Leiden', 'uniID' => 'lei'), $uniMaastricht = array('uniNaam' =>'Maastricht University', 'uniID' => 'um'), $uniNijmegen = array('uniNaam' =>'Radboud Universiteit Nijmegen', 'uniID' => 'run'), $uniRotterdam = array('uniNaam' =>'Erasmus Universiteit Rotterdam', 'uniID' => 'eur'), $uniTilburg = array('uniNaam' =>'Tilburg University', 'uniID' => 'uvt'), $uniTwente = array('uniNaam' =>'Universiteit Twente', 'uniID' => 'ut'), $uniUtrecht = array('uniNaam' =>'Universiteit Utrecht', 'uniID' => 'uu'), $uniWageningen = array('uniNaam' =>'Wageningen University', 'uniID' => 'wur') ); /////////////end///////////// ///Variabelen declareren/// ///////////////////////////// /// Aan iedere universiteit de HodexURL toevoegen foreach( $universiteiten as $universiteitkey => $universiteit ) { echo '<strong>' . $universiteit['uniNaam'] . ':' . '</strong> <br />'; foreach( $hodexDirectory->hodexEntity as $school ) { if ( $universiteit['uniID'] == $school->orgUnitId ) { $hodexURL = (string) $school->hodexDirectoryURL; $universiteiten[$universiteitkey]['uniURL'] = $hodexURL; echo 'Universiteit ID: ' . $universiteit['uniID'] . '<br />'; echo 'Hodex URL: ' . $hodexURL . '<br /><br />'; } } }
  8. Thanks requinix. Within the foreach loop it works ! But when i try to get the ['uniURL'] outside the foreach for a university it's not working. it looks like the array within $universiteiten isn't updated with a new associative value (['uniURL']) Like: foreach( $universiteiten as $universiteitkey => $universiteit ) { echo '<strong>' . $universiteit['uniNaam'] . ':' . '</strong> <br />'; echo $universiteit; foreach( $hDirectory->hEntity as $school ) { if ( $universiteit['uniID'] == $school->orgUnitId ) { $hURL = (string) $school->DirectoryURL; $universiteiten[$universiteitkey]['uniURL'] = $hURL; echo 'Universiteit ID: ' . $universiteit['uniID'] . '<br />'; echo 'Hodex URL: ' . $hURL . '<br /><br />'; // this works fine } } } echo $hURL // doesn't work echo $uniUtrecht['uniURL']; //here the output is missing Will output an error that the 'uniURL' is missing.. It seams like i cannot reach for the 'uniURL' outside of the IF Statement. foreach() { foreach() { if() { here i can access the ['uniURL'] } here i've lost ['uniURL'] } here i've lost ['uniURL'] } here i've lost ['uniURL'] What am i doing wrong here?
  9. First: i'm pretty new to PHP. Second, the situation: i've got a array of universities. Each university within the array, which is also an array has values like an ID and Name. I wan't to add a value to that university from a xml feed, a URL. I can match ID's to find the corresponding university in the xml feed. Third, my question: Why do i lose the ['hURL'] outside of my foreach loop(s) ? It's working inside the foreach loop ... Fourth, here's the code: $hDirectory = get_xml_feed('http://myawesomefeed.xml'); $universiteiten = array( $uniUtrecht = array('uniNaam' =>'Universiteit Utrecht', 'uniID' => 'uu'), $uniWageningen = array('uniNaam' =>'Wageningen University', 'uniID' => 'wur') ); foreach( $universiteiten as $universiteit ) { echo '<strong>' . $universiteit['uniNaam'] . ':' . '</strong> <br />'; foreach( $hDirectory->Entity as $school ) { if ( $universiteit['uniID'] == $school->orgUnitId ) { $hURL = (string) $school->DirectoryURL; $universiteit['uniURL'] = $hURL; echo 'Universiteit ID: ' . $universiteit['uniID'] . '<br />'; echo 'Hodex URL: ' . $universiteit['hURL'] . '<br /><br />'; //this works just fine } } } echo '<br/>'; print_r_html($uniUtrecht); // but here the [hURL] is missing
×
×
  • 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.