Re: eregi function?

From: Date: Tue, 25 Nov 2003 23:07:55 +0000
Subject: Re: eregi function?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-170955@lists.php.net to get a copy of this message
Jas wrote:
Not sure how to do this but I have a call to a database which pulls the contents of a table into an array and I need a eregi string which will sift through the contents and put a line break (i.e. \n or <br>) after each ";", "}" or "{". here is what I have so far... while($b = mysql_fetch_array($sql)) { list($id,$date,$user,$level,$global,$vlan01,$hosts01,$vlan02,$hosts02,$vlan03,$hosts03,$vlan04,$hosts04,$vlan05,$hosts05,$vlan06,$hosts06,$vlan07,$hosts07,$vlan08,$hosts08,$vlan09,$hosts09,$vlan10,$hosts10) = $b; }
    if(!eregi("^[{]+[}]+[;]$", $id,$date,$user,$level,$global,$vlan01,$hosts01,$vlan02,$hosts02,$vlan03,$hosts03,$vlan04,$hosts04,$vlan05,$hosts05,$vlan06,$hosts06,$vlan07,$hosts07,$vlan08,$hosts08,$vlan09,$hosts09,$vlan10,$hosts10)) 
// insert line break here } Any help with this would be appreciated Jas
You could always do: $string = str_replace(array(';', '{', '}'), array(";\n", "{\n", "}\n"), $string);

« previous php.general (#170955) next »