QUACK
Members-
Posts
11 -
Joined
-
Last visited
Never
Profile Information
-
Gender
Not Telling
QUACK's Achievements
Newbie (1/5)
0
Reputation
-
Hmm that works wounderfully for some reason :D thank you all for your help :)
-
But intersect removes hey.txt and diff doesent include Wow => 'OK!' ... Im trying to get the end result of the the array to be [code]Array ( [0] => hey.txt [Wow] => Array ( [0] => OK! ) );[/code]
-
No change just says Array ( )
-
No luck with either thoes two functions.
-
From $moo [code]array ( 0 => 'hey.txt', 1 => 'logo.gif', 'Wow' => array ( 0 => 'cool.gif', 1 => 'Saved Game', 2 => 'OK!' ,), )[/code] From $cow [code]array ( 0 => 'logo.gif', 'Wow' => array ( 0 => 'cool.gif', 1 => 'Saved Game' ), )[/code]
-
Okay that worked for that example array but it dident for some reason on this: I had $cow set to [code]Array ( [0] => logo.gif [WOW] => Array ( [0] => cool.gif [1] => Saved Game ) )[/code] and $moo set to [code]Array ( [0] => hey.txt [1] => logo.gif [WOW] => Array ( [0] => cool.gif [1] => Saved Game [2] => OK! ) )[/code] I SHOULD have been left with [code]$res = Array ( '0' => 'hey.txt', 'WOW' => Array ( '0' => 'OK!' ) ); [/code]but it returned nothing :/ why ? Thanks.
-
Basicly, I have an array called say, $moo ... and another $cow. [code]$cow = array ( '0' => 'Hey', '2' => 'Woo', '3' => 'Poop', '4' => 'Cool!', 'YAY' => Array ( '0' => 'Hi', '2' => 'Boo' ) ); $moo = array ( '0' => 'Woo', '2' => 'Hey', '3' => 'Nice!', 'YAY' => Array ( '0' => 'Hi' ) );[/code] How can I run though $moo and remove all the values that $cow has from $moo ... So in the end, $moo becomes: [code]$moo = array ( '3' => 'Poop', '4' => 'Cool!', 'YAY!' => Array ( '2' => 'Boo' ) );[/code] So $cow and $moo both have Hey and Woo so we remove that from $moo ... they both have YAY => Hi so remove that $moo too. Thanks for the help :)
-
I am trying to retrieve multipule and refresh them all after 5 seconds. [code] <div id="header"> <img src="/images/heading3.gif"> </div> <div class="news" id="news1"><!-- Empty div for dynamic content -->Loading news. please wait...</div> <div class="news" id="news2"><!-- Empty div for dynamic content -->Loading news. please wait...</div> <div class="news" id="news3"><!-- Empty div for dynamic content -->Loading news. please wait...</div> </div> <script type="text/javascript"> ajax_loadContent('news1--external/externalfile1.html'); ajax_loadContent('news2--external/externalfile2.html'); ajax_loadContent('news3--external/externalfile3.html'); [/code] [code]function ajax_showContent(divId,ajaxIndex,data) { document.getElementById(divId).innerHTML = dynamicContent_ajaxObjects[ajaxIndex].response; dynamicContent_ajaxObjects[ajaxIndex] = false; settimeout("ajax_loadContent('"+data+"')",5000); } function ajax_loadContent(data) { data = data.split ( '--' ); var ajaxIndex = dynamicContent_ajaxObjects.length; dynamicContent_ajaxObjects[ajaxIndex] = new sack(); dynamicContent_ajaxObjects[ajaxIndex].requestFile = data[ 1 ]; // Specifying which file to get dynamicContent_ajaxObjects[ajaxIndex].onCompletion = function(){ ajax_showContent(data[0],ajaxIndex,data); }; // Specify function that will be executed after file has been found dynamicContent_ajaxObjects[ajaxIndex].runAJAX(); // Execute AJAX function } [/code] It loads the 3 pages then stops, it doesent do it agian after 5 seconds. If anyone has a better way of doing it, im welcome to suggestions :D thanks.
-
ah $block . $match[ 0 ] worked >.< all i had to do was switch it haha thanks very much it does: Value: 0 Value: 1 Value: 2 :) and ur statement was correct, it leave the block there and adds more too it until it deleted, simpel and works.
-
I created a template class in Python worked perfect. I decided to convert it to PHP. It works as expected execpt one thing. When I do a loop and assign the block it counts backwards. Ill explaine ... [code]<?php ######################################################### # FILENAME: template.php # COPYRIGHT: (C) 2006, Kyle King (aibotca@yahoo.ca ) ######################################################### ######################################## # Class: Template # 1: set_file. # 2: assign_vars. # 3: assign_block. # 4: delete_block. # 5: parse. ######################################## class Template { var $new_tpl; ######################################## # Function: set_file # 1: template, string. ######################################## function set_file ( $template ) { # Set new_tpl to the contents of $template $this->new_tpl = file_get_contents ( $template ); } ######################################## # Function: assign_vars # 1: array, array. ######################################## function assign_vars ( $array ) { # Loop though the array. foreach ( $array AS $key => $value ) { # Replace the key with the value in new_tpl. $this->new_tpl = str_replace ( '{' . $key . '}', $value, $this->new_tpl ); } } ######################################## # Function: assign_block # 1: block_name, string. # 2: array, array. ######################################## function assign_block ( $block_name, $array ) { # Get all the block, put them in an array. preg_match ( '#<!-- BEGIN ' . $block_name . ' -->\n(.+)\n<!-- END ' . $block_name . ' -->#', $this->new_tpl, $match ); $block = $match [ 1 ]; # Loop though the array. foreach ( $array AS $key => $value ) { # Replace key with value in block. $block = str_replace ( '{' . $block_name . '.' . $key . '}', $value, $block ); } # Replace keys with old keys + block in new_tpl. $this->new_tpl = str_replace ( $match[ 0 ], $match[ 0 ] . $block, $this->new_tpl ); } ######################################## # Function: delete_block # 1: block_name, string. ######################################## function delete_block ( $block_name ) { # Get rid of the old keys and blocks. $this->new_tpl = preg_replace ( '#<!-- BEGIN ' . $block_name . ' -->\n(.+)\n<!-- END ' . $block_name . ' -->#', '', $this->new_tpl ); } ######################################## # Function: parse ######################################## function parse ( ) { # Print it out onto the page ^^ print $this->new_tpl; } } $template = new Template ( ); $template->set_file ( 'example.tpl' ); $template->assign_vars ( array ( 'L_EXAMPLE' => 'Example One ...', 'L_EXAMPLE2' => 'Example Two ...' ) ); for ( $i = 0; $i < 3; $i++ ) { $template->assign_block ( 'example_block', array ( 'S_LOOPTEST' => 'Value: ' . $i ) ); } $template->delete_block ( 'example_block' ); for ( $x = 0; $x < 3; $x++ ) { $template->assign_block ( 'example_block2', array ( 'S_LOOPTEST2' => 'Value: ' . $x ) ); } $template->delete_block ( 'example_block2' ); $template->parse ( ); ?>[/code] [!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--] for ( $i = 0; $i < 3; $i++ ) { $template->assign_block ( 'example_block', array ( 'S_LOOPTEST' => 'Value: ' . $i ) ); } $template->delete_block ( 'example_block' );[/quote] Thats what does the looping :/ Now this is whats in example.tpl: [!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]{L_EXAMPLE}<br />{L_EXAMPLE2} <br /> <br /> <!-- BEGIN example_block --> {example_block.S_LOOPTEST}<br /> <!-- END example_block --> <br /> <br /> <!-- BEGIN example_block2 --> <b>{example_block2.S_LOOPTEST2}</b><br /> <!-- END example_block2 -->[/quote] It outputs [code]Example One ... Example Two ... Value: 2 Value: 1 Value: 0 Value 2: 2 Value 2: 1 Value 2: 0[/code] Why is it going backwards :(. See assign_block in the PHP code thats what does the block :( Thanks