Showing posts with label php functions. Show all posts
Showing posts with label php functions. Show all posts

Wednesday, September 3, 2008

Substring function in php

<?php
header ('Content-type: text/html; charset=utf-8');
echo $haystack = 'Iñtërnâtiônàlizætiøn';
 
$substr = substr($haystack, 0, 13); // Position 13 is in the middle of the ô char
 
print "Substr: $substr<br>";
?>

php simple xml read

<?
if (!$myxml=simplexml_load_file('process.xml')){

    echo 'Error reading the XML file';

    }
        echo $chaptername=$myxml->chapterid->name;
        echo "<br>";
       
    foreach($myxml->table as $movie){

        echo 'name: ' . $movie . '<br />';   

       

    }

?>


php yesterday date format

<?php
$m=date('m');
$d=date('d');
$y=date('Y');
echo $todaydate=date('Y-m-d');
$yday=date("Y-m-d", mktime(0, 0, 0,$m,$d-1,$y));
echo "<br>";
echo $yday;
?>

Thursday, August 7, 2008

Single Command Replace matching pattern

 find  rootfolder  -name  "*.html" -exec sed -i 's/oldname/newname/g' {} \;

Tuesday, July 15, 2008

replace single command

find /sitename/foldername/ -name  "*.html" -exec sed 's/oldtext/newtext/' {} \;