![]() |
How to change eregi() to preg_match() - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21) +--- Thread: How to change eregi() to preg_match() (/showthread.php?tid=35337) |
How to change eregi() to preg_match() - El Forum - 10-26-2010 [eluser]ibon[/eluser] Please anyone help me,. <?php $headers = array_keys($csv[0]); foreach ($headers as $v){ $hdr = trim(str_replace('"','',$v)); if ($hdr != '' && !eregi("thumbnail",$hdr) && !eregi("image",$hdr)){ echo "<th>".$hdr."</th>\n"; } } ?> <?php foreach ($csv as $key => $line){ echo "<tr align='top'>\n"; foreach ($line as $f => $d) { $FIELD = trim(str_replace('"','',$f)); $FDATA = trim(str_replace('"','',$d)); if ($FIELD != '' && !eregi("thumbnail", $FDATA) && !eregi("image", $FDATA)){ echo "<td>"; echo $FDATA. "\n"; echo form_hidden("line_$key"."[".$FIELD."]", $FDATA); } } echo "</tr>\n"; } ?> How to change eregi() to preg_match() - El Forum - 10-26-2010 [eluser]WanWizard[/eluser] Code: preg_match('/thumbnail/i', $hdr) How to change eregi() to preg_match() - El Forum - 10-26-2010 [eluser]InsiteFX[/eluser] This may help others looking for this information. Code: Fix `ereg is deprecated` errors in PHP 5.3 InsiteFX How to change eregi() to preg_match() - El Forum - 10-26-2010 [eluser]ibon[/eluser] to WanWizard : Thanks a lot, it work ! :-) and to InsiteFX : Thanks for references ![]() I still got a problem with this code and how to fixed ? especially split() function parseLines($p_CSVLines) { $content = FALSE; foreach( $p_CSVLines as $line_num => $line ) { if( $line != '' ) { // skip empty lines $elements = split($this->separator, $line); if( !is_array($content) ) { // the first line contains fields names $this->_fields = $elements; $content = array(); } else { $item = array(); foreach( $this->_fields as $id => $field ) { $item[$field] = $elements[$id]; } $content[] = $item; } } } return $content; } How to change eregi() to preg_match() - El Forum - 10-26-2010 [eluser]ibon[/eluser] It Work when I change with this : preg_split("/$this->separator/", $line); |