Skip to main content

Posts

Showing posts with the label PHP Code

Convert excel to CSV file using PHP, Linx Server

How to convert xls file into csv file using php or LAMP, Look at simple example to convert excel to csv file using php on linux server. <?php require_once 'Excel/reader.php'; $excel = new Spreadsheet_Excel_Reader(); $excel->setOutputEncoding('CP1251'); $excel->read('b.xls'); $x=1; $sep = ","; ob_start(); while($x<=$excel->sheets[0]['numRows']) { $y=1; $row=""; while($y<=$excel->sheets[0]['numCols']) { $cell = isset($excel->sheets[0]['cells'][$x][$y]) ? $excel->sheets[0]['cells'][$x][$y] : ''; $row.=($row=="")?"\"".$cell."\"":"".$sep."\"".$cell."\""; $y++; } echo $row."\n"; $x++; } $fp = fopen("data.csv",'w'); fwrite($fp,ob_get_contents()); fclose($fp); ob_end_cl

Set php.ini values into .htaccess file

How can i set php.ini configuration values into .htaccess file? Here is the simple solution to set php.ini variables into .htaccess file. Syntax non flag variables. php_value setting_name setting_value Example : php_value upload_max_filesize 10M Syntax for flag variables such as (on/off). php_flag [variable_name] [value] Exmaple : php_flag register_globals off

How To Read RSS Using PHP

Here is the simple code to read RSS Feeds using php with simpladxml_load_string function. CODE: 1 :   <?php 2 :        $displayItems = 5; 3 :        $itemCounter = 0; 4 :        $rss = simplexml_load_file("http://put here url of RSS Feed"); 5 :        foreach($rss->channel->item as $feeds){ 6 :             $itemCounter++; 7 :             echo '<li><a href="'.$feeds->link.'">'.$feeds->title.'</a><br /><br />'; 8 :             if($itemCounter==$displayItems)break; 9 :        } 10 :   ?>

Search Records into XML Using PHP

There is an example for search items or block into xml using php with simplexml_load_string method or function, this will return you record block for particular query. query = us CODE: 1 :   <?php 2 :        # parm query=delhi , us 3 :        $xmlStr = '<?xml version="1.0" encoding="utf-8"?> 4 :                            <temprature> 5 :                            <item> 6 :                                 <city>Bareilly</city> 7 :                                 <state>Uttar Pradesh</state> 8 :                                 <country>India</country> 9 :                                 <lat>32.4567</lat> 10 :                                 <lon>34.4567</lon> 11 :                                 <temp>43.0</temp> 12 :                            </item> 13 :                            <item> 14 :                                 <city>Haldwani</city&