Delete New Lines
I would like to delete the new lines, I mean the, so Itried this:
str_replace($row['facts_conten t'], "
", "") ;
But the new lines are still there, how can I do?
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Delete Lines From File:
How to delete $n first lines from $str if i know how much lines shuld remain in the string? $str = "aaaaaaaaa bbbbbbbb ccccccccc ddddddddd ... zzz"; Can it be done easly with preg_replace? (i.e without splitting it by '', removing elements from array and joining tham back.
How To Delete N Lines From The Top Of A File?
I'm not sure how to do this in php - need to calculate and delete an unspecified number of lines from the *top* of a file. <?php //append $visitor to the bottom of $visdata $fp = fopen($visdata,"a"); fwrite($fp, " ".$visitor;) //count the lines in $visdata $lines = count($visdata); if $lines > 10 { //delete as many lines off the top as necessary //to end up with 10 lines total in $visdata } fclose($fp); ?>
Blank Lines Between Lines Of Text
how do i put a blank line between lines of text on my webpage using php eg within my while loop printf("<a href="%s?id=%s">%s %s %s %s </a><br> ",$PHP_SELF,$myrow["id"], $myrow["first"], $myrow["last"], $myrow["email"],$myrow["details"]); printf("");//this is what i thought might workdoes not work.
Few Lines Of C++ To PHP
How would i do this in php ? (from borland c++) for (int i=1; i<=myString.Length(); ++i) { returnValue += StrToInt(AnsiString("0x" + (AnsiString)myString[i]));
Splitting Lines
I have a form with a textbox for an entire address and I want to split it into each line to print upon submission but don't know how! Can someone point me in the right direction? If it'd be easier to split it into separate lines I'll do that but I'd prefer to keep it as it is.
Converting New Lines To <br>
I have some data contained in a mySQL table that contains line breaks. It's a snail-mail address. How can I have it so that when the data is recalled via PHP it puts a <br> where the newline is so that the data appears on a new line?
Number Of Lines
Is there a function that returns the number of lines in a text file? If so, what is it?
How To Number 42 Lines 1-14
I have 3 sonnets (14-line poems, fyi) in a file without blank lines and I want to tack line numbers onto the end of each line so that the first 14 lines will be numbered 1-14, as will the second 14 lines and the third. I've exploded the file by " " so that I have each line as an array value. I've been using various loop fuinctions (for, foreach, while) to try to put individual numbers at the end of each corresponding line, but something either loops too much or not at all. This is just an example. I know I could number 42 lines by hand, but I'd like an automated system to do it for much more line numbers.
Textarray And New Lines
I have a textarea in which users can enter text. When submitted the data is stored in a database. This works fine except when a new line is inserted (enter). This is not stored in the database. Is it possible to do this?
Matching Lines
I am trying to grab the lines from a textarea that match a substring. How best to implement this? I tried regex and failed miserably. Here I try to match every line with
New Lines In Form
it is time for some fine tuning of my application, after adding that banner script for which I needed percentage solution, I would like to fix my forum scripts... when someone write some text in form's textarea and then enter new line (btw, is that or or combination?) I'm not "getting" that new line but space. what can I do to "recieve" and store (in mysql db) text with newlines instead of spaces. and, even better, to replace that newline with </p> <p>...
Unexpected $ (about 70 Lines)
I get this error: Parse error: parse error, unexpected $ in [file] on line 63 Where [file] is the path and filename for a file containing: <?php function cityname($style="10engdir eng 50engloc"){//creates name for city return 'a city' }; function powercentres($pop){//determines power centres for a city return array(1=>array('name'=>'pc1','align'=>'true neutral','views'=>array(1=>'self'),'type'=>'conventional')); $pcs=array(); if($pop<=80){ $roll=rand(1,20); $align=rand(1,100); if($align<=35){ $pcs[1]=array('align'=>'lawful good'); }elseif($align<=39){ $pcs[1]=array('align'=>'neutral good'); }elseif($align<=41){ $pcs[1]=array('align'=>'chaotic good'); }elseif($align<=61){ $pcs[1]=array('align'=>'lawful neutral'); }elseif($align<=63){ $pcs[1]=array('align'=>'true neutral'); }elseif($align<=64){ $pcs[1]=array('align'=>'chaotic neutral'); }elseif($align<=90){ $pcs[1]=array('align'=>'lawful evil'); }elseif($align<=98){ $pcs[1]=array('align'=>'neutral evil'); }else{ $pcs[1]=array('align'=>'chaotic evil'); } if($roll-1<=13){ $pcs[1]['type']='conventional' if(rand(1,20)==1){ }elseif($roll-1<=18){ $pcs[1]['type']='nonstandard' }else{ $pcs[1]['type']='magical' } };
Empty Lines
i read the filr into an array using file(). some of the lines are empty. i would like to output the file but ignoring the emnpty lines.
New Lines In Forum
I've just made a forum. When entering text into a textarea for a post, i press enter to begin a new line but on viewing the post it puts the message on one single line which i don't want. How can i make it keep record of the user starting new lines.
Can I Read TextFiles By Lines With PHP
I will get via a submit button a lot of data to my PHP Script. Every variable contains a number which leads to line number in a textfile(readonly). It seems to be quite easy: i have my filepointer and then i thought the command "fgets" is doing this job for me but when i try $buffer=fgets($myFilePointer, $myLineNumber); i will just get the amount of characters from the first line defined in $myLineNumber. It seems to be so easy. How are you dealing with standard .conf Files? There they are doing the same (f.e. httpd.conf).
Open Multiple Lines Up
I have a form that fills itself out using php and mysql going by an id number out in by a user, but some users have more than one line of the form from the same number and all I can get to com up is the first line it comes to, how do i get it to get the lines?
Checking For Number Of Lines?
I have a problem. I have a static table cell (static meaning that it's dimensions do not change per amount of data) and i want to put news there. Via a mysql database i am outputting the news into this cell, but i want it to only allow enough so that it fits. Is there a way I can see how many lines a string has, or is there some other way to do this?
Stripping Out Spaces And New Lines
I am trying to write a script that will go in to an included php file, strip out some things and save it back out. So far, so good. The problem is when netscape navigator gold editor is used it does some things to the code that is creating havoc when the page is displayed. I wish that using that as an editor was NOT a choice but that is what the client uses sooooo... Anyway, here is the problem:
How To Count Lines From A Form?
I'm having trouble working this out ... Is there a simple way to count how many lines are returned in $_POST['myTextArea'] When I look at the $_POST all I see is one line yet there are three. I assume something is being interpreted differently depending on how I view it. Is there a simple funtion for this or can someone tell me how to work it out please?
Read First 10 Lines From A File
I have an ASCII file with each data record on a separateline. Each field is delimited with a TAB (ASCII 9) character. Now i want to read the first 10 lines and show them on my site. This is what i already have reading the first line: $fname = "http://www.somedomain.com/file.txt"; $fd = fopen($fname, "r"); if ($fd) { if (!feof ($fd)) { $buffer = fgets($fd, 4096); $field = split(chr(9), trim($buffer)); $field0 = "$field[0]"; $field1 = "$field[1]"; } fclose($fd); } echo ("$field0 - $field1"); How can i do this voor the first 10 lines?
Split A String Into Some More Lines
I have a problem with PHP. If I had a string with a lot of text, how can I then make a function, which can split the text up in some more lines, if I define how long the line have to be, and it shouldn't split up the words just when there are whitespaces...
Anti-Aliasing Of Lines In PHP Through GD
looking at the manual of GD, I see that there is the functionality to draw anti-aliased lines. However, in the recent PHP documentation, I can't find an appropriate image function to set anti-aliasing to TRUE. Can someone tell me the recent status of the PHP implementation on this?
Echo Multiple Lines At Once.
Some of the online docs say that you can use echo <<<END all sorts of text and statements... END; but if the following produces a parse error at line 14 which is the closing php tag. <?php echo <<<TT <tr> <td> <p>1. some text...</p> </td> <td> <p> <input type="radio" name="gs.$i" value="1"> </p> </td> </tr> TT; ?> Any suggestions, like don't use this tag?
How To Loop Through Lines In A File?
I have an array ($data_array) and I want to compare each line of a text file ($counter_file) to each element of the array (the array and the file are in sync line-for-line). But the file is very big and I don't want to read the entire file into an array. In the interest of efficiency, I thought I'd open the file as read only and loop through and compare each line to the array - since I have to open the file later in append mode, I thought something like this would work. But how do I advance the pointer to the next line in the file as the loop increments? $fp = fopen($counter_file, "r"); for (i=0; i < count($data_array); i++) { $recent_visit = fgets($fp); //<<== * ? // * how to go to next line as i increments? if ($recent_visit < TIME1h) { $dup_line = explode("|", $data_array[i]) $dup_ip = trim($dup_line[i]); if ($visip == $dup_ip) //no dupes within one hour { exit; } } else { break; } } $fp = fopen($counter_file, "a"); [append stuff to counter_file here]
Remove All Lines Starting With B
Say I have the following file - dummy.txt: a 4treg a sdfas a 4egdsag b 1111 a ergdsfg b 1111 c waefasdf How would I go about removing all the lines that begin with a b? I thought the following script (which I wrote with the intention of replacing all such lines with the empty string) would but apparently it doesn't: <? $contents = file_get_contents('dummy.txt'); echo ""; echo preg_replace('/^b.*? /','',$contents); ?>
Changing New Lines To Html
how would I go about changing the to a <br> command for a flat file system? When I say I mean when the user hits enter in a textarea I want it 2 store a <br> and not a in the text file.
Tabs And New Lines And OUTFILE
I have a form with a textarea and users often include new lines and tabs in their entry (much like I am doing here) and also "quotes". When Selecting this table into the outfile (it is then ftp'd down for opening in Excel) the new lines and tabs are creating new rows. I have tried using different field delimiters like | [pipe symbol] which seems to help with the tab problem but does not solve the new line problem. I am reluctant to string replace as I store the data because keeping the spacing looks much better when the data is displayed on the web site.
Parsing Lines With Breaks
Although my code working fine, all the PHP parsing seem to occupy one entire line when the page's source is displayed. Is there away to "break" lines during parsing? That way, the source won't look messy. Here's what I'm trying to say: Code:
Splitting Lines In Arrays?
Been staring at this for a couple of hours now and I find myself completely bewildered. I suppose it doesn't help that I'm a php newbie. Nevertheless, I throw myself at your mercy. I have an array which I am attempting to split off into a new array. The first array is just a whole bunch of links like so: http://www.example.com/query?track=...om/whatever.php http://www.example.com/query?track=...m/whatever1.php I managed to (sorta) successfully extract things out using preg_split: foreach ($http_array as $i) { $split = preg_split("/=/", $i, 2); print "$split[1]<br>"; } and the output looks like The main goal is to parse an array much like the first bit at the top, lop off anything after the first "=" in the line and then place it all into another blank array so that I might do something else clever elsewhere with it. however, i've been totally unsuccessful in cleaning out blank entries in the array (some creep in there, PREG_SPLIT_NO_EMPTY does not seem to catch them) and cramming all of that into another new array. Been back and forth between google and the fine php documents with little to show for it.
Edit Lines In Txt File
i am trying to write data that i have stored in a session back to a member.txt, but i am unable to work out why it wont write. It displays the data i have stored in the session ok, but it wont do the next step! I have used a similiar script in another part of my web page which works, but this one won't. From my understanding it has something to do with if statement if($data[0] == $user_id), so i might be trying to compare the previouis data to the current data stored in the txt file properly....
Read Last Few Lines (array_reverse)
I want to read last few lines (suppose 10) from of file. array_reverse(file($f)) is not a good way I think bcoz if file become large, this is performance issue. any other way to do that?
Printing Only Two Lines From A File
I have a file (file01, i.e) like this: foo foo foo bar foo bar foo .... Where foo and bar repeats n times, but only foo and bar. What i want to print is just: foo bar I have tried this: $myfile=file("file01"); $current_line = reset($myfile); $first_line = $current_line; print("First line is: $first_line"); while ($current_line=next($myfile)) { if ($current_line != $first_line) { print("The other line is: $current_line"); break; } } and it works as stand alone, but in the real application, i get: Fatal error: Cannot break/continue 1 level in /var/www/html/web/include/functionShow.inc on line 172
Using File() With Blank Lines
Let me admit right up front this is my first foray into php. I'm trying to simply use a small data file to populate a page. I'm using the file() function but I want my "data records" to be seperated by a double My problem is I can't seem to compare a line to anything. My first problem was determining the end of a data block, finding the double newline. But in frustration, I just tried to compare a line to a known value and I still can't compare strings correctly. Here's a sample data file:
Blank Lines In Files
I am using PHP to read a file and I was just using fgets to get my line and using a for-loop until the line was EOF, then I would break out of my loop. I noticed this has a problem when the file I read from has blank lines at the end. I have tried to ignore these blank lines at the end of the file but I cannot get them to be ignored. My code looks like: Code:
Confining Text From DB To 5 Lines
Basically I have an article in a Database and I would like it to display in an HTML table but I only want it to show up to 5 lines. I'm not sure how I can accomplish this.
E-Mail Not Breaking Lines
I'm sending an e-mail via a contact form, but somehow the lines aren't breaking in the text, it always looks like this: lorem ipsum dolor sit amet lorem Which is of course not readable at all. What am I doing wrong here? I'm using a few security checks and such for cleaning the field up; $text = trim($text); ... $text = stripslashes(strip_tags($text)); ... $text = mysql_real_escape_string($text); ..... #and then the part where it's included in the message: $message .= "Nachricht: {$text} "; Can any of those be causing the display problem?
Html Output Lines
given that php echo '<div>' echo 'whatever' echo '</div>' echo '<div>' echo 'whatever' echo '</div>' echo '<div>' echo 'whatever' echo '</div>' echo '<div>' echo 'whatever' echo '</div>' the output html is <div>whatever</div><div>whatever</div><div>whatever</div><div>whatever</div> whereas I would like to have as output the following (It's better in order to read and understand the html code) <div> whatever </div> <div> whatever </div> <div> whatever </div> <div> whatever </div> How should I do ?
Deleting Blank Lines
Does anybody know of a script that will delete all the line breaks/blank lines in all my PHP scripts automatically... or how i could go about making one / easily
Executing Command Lines...
I'm trying to execute a command line through ffmpeg.exe in php. Can anyone tell me how this is done. Also where should I have such an application installed relative to the root of the site?
Display First 4 Lines Of An Article
I am a php newbee and I am building a CMS which stores articles in a database. I know how to display the whole article but what I want to do is to get an article from the database and display the first 4 lines of that article with a link for readers to read the whole article. so I was wondering is there anyway way to do this.
Remove Break Lines
Say i have a variable with this as its input: G f h s hhss s f when this is inputted into the database it goes in completely blank.. so was wondering if theres a way to remove the lines to make just spaces? so it would become G f h s hhss s f is this possible?
Allowing New Lines Within Comments
i have a script where i check the content that the user inputs and works perfect. But ive found when i click enter for a new line it will return false how can allow a new line.
Remove Of Two Header Lines?
What I am trying to do here is remove two lines at the top of a text file using a script. Below is my script. I was trying to say in the script is that if it is not numeric then continue which would remove the lines. I am doing something wrong cause I can't get it to work. The included script is for logging only....
All I Need Is A Couple Of Lines Added To My Script.
categories table info : id: unique auto increment parent_id: all master categories =0 sub categories = id of its master category name : name of category The script I've written is supposed to each master category in the table followed immediately by any sub-categories it may have. If a particular master category does not have any subcategories it should fetch the next master category. My script works fine up to the point where the table contains a few subcategories before the next master category. At this point it lists out the subcategory (which has already been listed earlier within a master category) again assuming that it is a master category. All I need if an if or while statement in my script. I've tried different variations, but nothing worked. Here's the script:
Reading Multiple Lines From Mysql
I made a phpscript to enter data into my database, all works fine. I've got a <textarea> where i enter for example the following text (without the qoutes): "Hi, my name is Joey, i luv scripting and online gaming. I live in belgium, lovely country but bad weather" the script enters that text into the table. Another script of mine queries the database for the text, but it outputs: "Hi, my name is Joey, i luv scripting and online gaming. I live in Belgium, lovely country but bad weather" It's just one strait line and not the block i entered. Anyone know how i fix that? It also happens when i input 2 word or more in a <input type=text>. The data is in the table but when i reinput it into an <input type=text> (for editing) it only inputs one word.
|