3 kwi 2008

Zmiana wybranych tekstów w stringu na nagłówki H3

$description = preg_replace("/(PLA.A|POŁOŻENIE|Wy.ywienie|SPORT . ROZRYWK.|DLA DZIECI|DZIECI|Hotel|HOTEL|Hotel oferuje|HOTEL OFERUJE|Pokoje|INFORMACJE DODATKOWE|Położenie|Wyżposażenie|Dzieci|Zniżki|Rozrywka|Sport i zdrowie|Sport|NASZYM ZDANIEM|Kategoria|Region|All inclusive|Plaża|Umeblowanie|Rekreacja|Inne|Wyposażenie pokoi|O.rodek oferuje|Wyposa.enie hotelu|Wyposa.enie pokoju|POK.J SUPERIOR|Nasza opinia|Cena zawiera|Cena nie zawiera)\:/i", '<h3 class="k3 t3 mg2">\1:</h3>', $description);
3 kwi 2008

Utworzenie ikony dla mapy

var baseIcon = new GIcon();
baseIcon.iconSize = new GSize(32, 32);
baseIcon.shadowSize = new GSize(56, 32);
baseIcon.iconAnchor = new GPoint(16, 32);
baseIcon.infoWindowAnchor = new GPoint(16, 0);
var ikona = new GIcon(baseIcon, 'http://maps.google.com/mapfiles/kml/pal3/icon21.png', null, 'http://maps.google.com/mapfiles/kml/pal3/icon21s.png');

var point = map.map.getCenter();
var marker = new GMarker(point, ikona);
3 kwi 2008

Zmiana atrybutu class dla DIVa

var b_srch = document.getElementById('box');
var classN = 'wybgrs';

if (val == 'wlasny')
  classN = 'wybgrw';

if (b_srch.style.setAttribute)
  b_srch.setAttribute("className", classN);
else
  b_srch.setAttribute("class", classN);
2 kwi 2008

Wycięcie fragmentu tekstu zawartego miedzy tagami XML

Załadowanie XML:

$res = file_get_contents($url);

Wycięcie fragmentu tekstu:

$content_start  = strpos($res, '<content>') + strlen('<content>');
$head_end       = $content_start;
$content_end    = strpos($res, '</content>');
$foot_start     = strpos($res, '</content>');
$head    = substr($res, 0, $head_end);
$content = substr($res, $content_start, $content_end - $content_start);
$foot    = substr($res, $foot_start);
Konwersja nie zakodowanych znaków:
$content = str_replace("<",'<',$content);
$content = str_replace(">",'>',$content);
$res = $head . $content . $foot;