keithg

strtr – function in php

strtr — Translate characters or replace substrings $trans = array(“h” => “-“, “hello” => “hi”, “hi” => “hello”); echo strtr(“hi all, I said hello”, $trans); Out Put [crayon-5923027450202727318608/]Read more …
cavinz

Want To Know Column Of Any CSV File With PHP?!!!!!!! COME HERE

If You want to count your CSV File’s Column than do following, ini_set(“auto_detect_line_endings”, true); //  where it holds the end of the line $file = ‘sample.csv’; $handle = fopen($file,’r’); $data = fgetcsv($handle, 1000, “,”); echo ‘ TOTAL COUNT ‘ . count($data) . PHP_EOL; // will give you the top header...Read more …
cavinz

Order By Value in Query!!!!

If You want to make order as per your value than do following, $query = ” Order by FIELD(FILED_NAME, VALUES_WITH_COMMA)”; where e.g , VALUES_WITH_COMMA = ‘1’,’11’,’2′ FILED_NAME = ‘ID’  Read more …

How to replace the src attribute of the img tag from given html in php.

Here is the code for replace the ‘src’ attribute of the img tag from given html and return well formed html with new src content. $doc = new DOMDocument(); @$doc->loadHTML($html); $tags = $doc->getElementsByTagName(‘img’); foreach ($tags as $tag) { $old_src = $tag->getAttribute(‘src’); $new_src_url = WEBURL.$old_src; $tag->setAttribute(‘src’, $new_src_url); } $new_content = $doc->saveHTML();Read more …