Jump to content

wolves

Members
  • Posts

    65
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

wolves's Achievements

Member

Member (2/5)

0

Reputation

  1. Hi <?php function showmessage($key,$args) { //args = array with arguments to sprinf $messages = array( 'this is a test %s %s %s continue testing %s', 'this is other teste %s' ); echo sprintf($messages[$key],$args); //I cant use array args... //I need arg1, arg2, arg3 // how cant I do it? my messages have different number of arguments.... } ?> tks..
  2. working one PHP Version 5.2.0 non-working one PHP Version 5.1.0RC1
  3. <?php class defaultItemMenu { var $obj,$name,$link; function __construct($name,$link,$image,$args) { $img = ($image) ? image($image) : ''; $this->name = $name; if($link) { $link = ($args) ? _link(array( 'href' => '#', 'onclick' => "javascript:open_win('".$link."','".$args[0]."','".$args[1]."')"),$this->getName()) : _link(array('href' => $link),$this->getName()); } else $link = ''; if($link) $this->obj = '<li>' . $img . $link. '</li>'; elseif(!$this->getName()) $this->obj = '<li></li>'; else $this->obj = '<li>'.$this->getName().'</li>'; $this->link = $link; } function getName() { //não é um menu comum if(strstr($this->name,'<div')) return $this->name; else return str_replace('_','',$this->name); } function getLink() { return $this->link; } function toString() { return $this->obj; } } class rootItemMenu { var $childs = array(); var $name,$image; function __construct($name,$image) { $this->name = $name; $this->image = $image; } function addDefaultItem($name = null,$link = null,$image = null,$arg = array()) { $this->childs[$this->name][] = &new defaultItemMenu($name,$link,$image,$arg); } function addRootItem($name = null,$image = null) { $obj = &new rootItemMenu($name,$image); $this->childs[$this->name][] = $obj; return $obj; } } class rootMenu { var $defaultItens,$rootItens,$objects = array(); var $name,$link; function __construct($name,$link) { $this->name = $name; $this->link = $link; } function addRootItem($name,$image=null) { $this->rootItens[$name] = $obj = &new rootItemMenu($name,$image); $this->objects[] = $obj; return $obj; } function addDefaultItem($name =null,$link = null,$image = null,$arg = array()) { $this->defaultItens[] = $obj = &new defaultItemMenu($name,$link,$image,$arg); $this->objects[] = $obj; } function addSeparator() { $this->addDefaultItem(); } } class Menu { var $objects; function addRoot($name,$link = null) { $this->objects[] = $obj = &new rootMenu($name,$link); return $obj; } function toString() { $output = ''; foreach($this->objects as $objects) { $link = ($objects->link) ? _link(array('href' => $objects->link),$objects->name) : $objects->name; $output .= "<li> $link"; if($objects->objects) $output .= '<ul>'; foreach($objects->objects as $rootItem) { $output .= self::buildRoots($rootItem); } if($objects->objects) $output.= '</ul>'; $output.= '</li>'; } return '<ul id="_settimainmenu" style="display:none">' . $output . '</ul>'; } private function buildRoots($object) { $output = ''; if(is_a($object,'rootItemMenu')) { $output .= '<li> '; $output .= ($object->image) ? image($object->image) . $object->name : $object->name; $output .= '<ul>'; foreach($object->childs as $rootChilds) { foreach($rootChilds as $child) $output .= self::buildRoots($child); } $output.= '</ul></li>'; return $output; } elseif(is_a($object,'defaultItemMenu')) return $object->toString(); } public static function parseString($str) { $str = str_replace(array( ' ', '_', '/' ),array('','',''),$str); return retiraAcentos('item_'.strtolower($str)); } } ?> using this: <?php $menu = new Menu(); $root = $menu->addRoot('Section 1'); $a = $root->addDefaultItem('Section 1.1'); print '<pre>'; print_r($menu); print '</pre>'; ?> I'm getting 2 different results... localhost: <pre>Menu Object ( [objects] => Array ( [0] => rootMenu Object ( [defaultItens] => Array ( [0] => defaultItemMenu Object ( [obj] => <li>Section 1.1</li> [name] => Section 1.1 [link] => ) ) [rootItens] => [objects] => Array ( [0] => defaultItemMenu Object ( [obj] => <li>Section 1.1</li> [name] => Section 1.1 [link] => ) ) [name] => Section 1 [link] => ) ) ) </pre> other server ( [objects] => Array ( [0] => rootMenu Object ( [defaultItens] => [rootItens] => [objects] => Array ( ) [name] => Section 1 [link] => ) ) ) I Can't fix it... what can be? tks...
  4. some modifications.... <?php function ArrayLocate($srch,$haystack) { $out = array(); $cant = array(); foreach ($srch as $k => $v) { foreach ($haystack as $key => $h) { if (($h[$k] == $v) && !in_array($key,$cant)) $out[$key] = $key; else { $cant[] = $key; if(isset($out[$key])) unset($out[$key]); } } } return $out; } $haystack = array( array('id' => 1, 'name' => 'fernando', 'age' => 20,'adr' => 'blue'), array('id' => 2, 'name' => 'fernando', 'age' => 20,'adr' => 'green'), array('id' => 3, 'name' => 'jean', 'age' => 18), array('id' => 4, 'name' => 'paul', 'age' => 23), array('id' => 5, 'name' => 'bob', 'age' => 20), array('id' => 6, 'name' => 'richard', 'age' => 28), ); $z = ArrayLocate(array('name' => 'fernando','adr' => 'green'),$haystack); print_r($z); ?>
  5. Hi, I trying to build a function that can locate and return the key of an array.... something like $haystack = array( array('id' => 1, 'name' => 'fernando', 'age' => 20), array('id' => 2, 'name' => 'jean', 'age' => 18), array('id' => 3, 'name' => 'paul', 'age' => 23), array('id' => 4, 'name' => 'bob', 'age' => 20), array('id' => 5, 'name' => 'richard', 'age' => 28), ); echo ArrayLocate(array('age' => 18),$haystack); -> 1... 1 is the key of haystack that contain age = 18.... echo ArrayLocate(array('age' => 20),$haystack); -> Array(0,3)... 0,3 are keys of haystack that contain age = 20... echo ArrayLocate(array('age' => 20, 'name' => 'bob'),$haystack); -> 3... 3 is the key of haystack that contain age = 20 and name = 'bob'.... tks
  6. I have many values in the $_SESSION but When I open a new window using: function open_win(url,x,y){ url = window.open(""+ url +"","_blank","toolbar=no, location=no, directories=no, status=yes, menubar=no, scrollbars=yes, copyhistory=yes, width="+ x +", height="+ y +""); } my session is empty; BEFORE 'IN THE MAIN WINDOW' print_r($_SESSION); Array ( [foo] => 'bar' [bar] => 'foo' AFTER 'IN THE CHILD WINDOW' print_r($_SESSION); Array() note: this problem not occurs in FF. tks!
  7. HI I have 3 tables 1 - culture 2 - culture_local "local to cultivate" 3 - parameters "a daily params from whater of culture_local" there is about 12 culture_local registers culture_local needs a culture a culture can finish for 1 culture_local but not for other culture date_begin date_end description culture_local culture_id description parameters date culture_local_id culture_id temperature ph .... .... Ok, I use the culture_id from my culture_local to set culture_if for paramters but if I'm editing an old register... the culture_id is other for my culture_local and I can't check for the date, because there are some cultures in the same time what I have to do, to check the old culture? tks
  8. $result = mysql_fetch_array($count); print_r($result);
  9. now I need to compare ".pgm" files there is a away to do this in php? i looked at docs, but I found nothing about .pgm
  10. tks all especially Barand =)
  11. it is working but see this images http://www.set.eesc.usp.br/lamem/Texturas/Angelim.JPG http://www.set.eesc.usp.br/lamem/Texturas/Cedrilho.JPG they are total diferent analizing it by pixels, but not really total diferent the number of pixel is the number of different pixels so if u compare this other image http://www.set.eesc.usp.br/lamem/Texturas/PauBrasil.JPG will be 100% diferent too . . . complex images will always return 100% of diference  :-\
  12. it is creating a new image with all diferences between img 1 and img 2 but always 0% of diference, I will try to fix tks
  13. <?php echo calcprice($row_rs_ebicases['price'],$discnt); ?>
  14. "Seem" sorry but english is not my native language so it is bad :( ok I will put my problem.. I need to analyze images of pieces of wood, small pieces but good resolution Im my database there are lots of diferent images Now, I have a new image, so I have to compare to the others to see if I have this one or not. Why not a script that look the all the images and return me some images that looks like to my image not a perfect comparaison, but a aproximate
×
×
  • 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.