Exploding At Real Breaks Not Wraps
I am working on reading my pop3 email , and I am trying to return the header data using the function, I get this fine. The question I have is since there is no consistency to the rows, I want to take each row of data, not a wrap of a long line, any idea beyond checking if it has a : in it???
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Page Wraps
How do page wraps work so that if the search results go beyond like 15 itll go to a second page ... is there a built in function or do i have to manually make each page =/ ?
A Real Challenge For Real PHP Programmers
<?php /* A challenge to every PHP programmer.The one who's gonna solve this problem would be deemed as PSP(PHP Supreme Programmer).The problem is this : You have to write a script that displays a list of categories and subcategorieslike this one: <select name="category"> <option value="1">Main</option> <option value="2">Main > Computers</option> <option value="4">Main > Computers > Hardware </option> <option value="8">Main > Computers > Hardware > PC</option> <option value="7">Main > Computers > Hardware > Mac</option> <option value="9">Main > Computers > Hardware > Atari</option> <option value="11">Main > Computers > Hardware > PC > History of Pc</option> <option value="">etc...</option> </select> The categories and subcategories details are stored in these two tables in a MySQL database. -categories : the categories names and ids. -cat_relations : the relations between categories.It shows which subcategory belongs to which category. The belongings between categories can go very deep and the number of categories is unlimited. This script will create the two tables and fill them with sample data. All you need to do is to change the four variables below. You can send the script back to this email : yasbergy@yahoo.com. */ //Here starts the script. Please change the values of these variables to fit your settings $user = "prospective_PSP"; $database = "db"; $server = "localhost" ; $pwd = "" ; //Connection to the database that you created mysql_connect($server,$user,$pwd) ; mysql_select_db($database); //Creation of the two tables : categories and cat_relations $categories = " CREATE TABLE `categories` (`id` INT not null AUTO_INCREMENT, `name` VARCHAR(100) not null , PRIMARY KEY (`id`), INDEX (`id`), UNIQUE (`id`)) comment = 'The categories details' "; mysql_query($categories) ; $cat_relations = "CREATE TABLE `cat_relations` (`id` INT not null AUTO_INCREMENT, `daughter_id` INT not null, `mother_id` INT not null , PRIMARY KEY (`id`), INDEX (`id`), UNIQUE (`id`)) comment = 'Which category is the daughter of which category'"; mysql_query($cat_relations) ; //Filling the two tables with sample data $cats = array('Main','Computers','Countries','Hardware','S oftware','Programming languages','Mac','PC','Atari','Winamp','History of the PC','IBM','Components','High level','USA','NYC','LA','Manhattan','India','Winzi p'); for ($i=0;$i<count($cats);$i++){ $sql = mysql_query("insert into categories (name) values('".$cats[$i]."')"); } mysql_query("insert into cat_relations (daughter_id,mother_id) values (2,1),(3,1),(4,2),(5,2),(6,2),(7,4),(8,4),(9,4),(1 1,8),(12,8),(13,8),(10,5),(20,5),(14,6),(15,3),(16 ,15),(17,15),(18,16),(19,3)"); //Now you can have a look on them through phpMyAdmin ?>
Exploding String
I have a script I use to explode a string and grab variables. It works great on one server, but when I use it on a separate web site it doesn't work at all. This may be a permissions issue, but other php scripts work fine.
Exploding An Array
I have a file with multiple lines, each line contains information broken into three parts that is separated with commas: FILE: l0p0,l0p1,l0p2 l1p0,l1p1,l1p2 l2p0,l2p1,l2p2... I want to use this information in a script, so I call the file using the following command: $file=file("myfile.txt"); This breaks up the file into an array, with each key representing a different line. I want to further break down this array efficiently as possible so that each line is exploded by the comma. I'm wanting to get an output like this: Array ( [0] => Array ( [0] => l0p0 [1] => l0p1 [2] => l0p2 ) [1] => Array ( [0] => l1p0 [1] => l1p1 [2] => l1p2 ) [2] => Array ( [0] => l2p0 [1] => l2p1 [2] => l2p2 ) ) I tried using this line: $file=explode(","file("myfile.txt")); but what it seems to be doing is just exploding the word "Array" print_r $file[0][0] => "A" print_r $file[0][1] => "r" However, explode(",",$file[0]) seems to work. How can I explode my array without having to do an explode command each time I want to use a value?
Exploding Array
Here's my problem. I am reading from a text file using this: if (!file_exists($file)) { echo "Don't exist "; return false; } $fd = @fopen($file, 'r'); if (!is_resource($fd)) { echo "Error reading "; return false; } And it works fine. The data that will be read will always be in the text file in the form of one - two - three - alpha beta kappa delta epsilon 13.5pp 29.95eu Now I want to explode that array that was read so I use this: $arrayData = explode("-", fgets($fd, 4096)); print "first=$arrayData[0] "; print "second=$arrayData[1] "; print "third=$arrayData[2] "; print "fourth=$arrayData[3] "; which will give me first=one second=two third=three fourth=alpha beta kappa delta epsilon 13.5pp 29.95eu But I need to access the last two items (13.5pp and 29.95eu) of this array to split them off as well so that the final output I need would be like this: first=one second=two third=three fourth=alpha beta kappa delta epsilon.txt numpages=13.5pp cost=29.95eu How can I do that? Do I need to further explode $arrayData[3] using a space delimiter? Is there a way to grab the last two fields only because the length of the 'alpha beta kappa delta epsilon' will not always be the same but the numpages and cost will always be the last two elements in the array.
Exploding A Word?
HAven't figured this. I have a word like 'ABC' How would I explode this? My difficulty is that there's no separator to which explode by.
Exploding A String
Is it possible to have the results of an exploded string into 4 different arrays?? I have many lines of $strPingCurrentLine each containing url, email size and command details. I therefore hope for a way to push each exploded $strPingCurrentLine into Quote$arUrl = array(); $arEmail = array(); $arSize = array(); $arCommand = array(); Instead of for instance $arTemp = explode(" ", $strPingCurrentLine);
Exploding Array
I'm having a bit of trouble here with getting an array to explode. When I echo it, its is simply writing "Array" 49 times. Basically I just need to seperate my arrays with a coma so I can select those ids from my table. Anyone got any ideas? I'm new to php so I'm stumped. Code:
Exploding An Array, Kind Of ...
I have an array as follows $sounds = array(); $sounds['sound1'] = "fishes/1/sound.php"; $sounds['sound2'] = "fishes/2/sound.php"; $sounds['sound3'] = "fishes/3/sound.php"; $sounds['sound4] = "fishes/4/sound.php"; $sounds['sound5] = "fishes/5/sound.php"; $sounds['sound11] = "bears/1/sound.php"; etc etc...... What I want to be able to do have turn the above into this: include ("sounds/fishes/1/sound.php"); include ("sounds/fishes/2/sound.php"); print ("<br>divider<br>"); include ("sounds/fishes/3/sound.php"); include ("sounds/fishes/4/sound.php"); print ("<br>divider<br>"); include ("sounds/fishes/5/sound.php"); include ("sounds/birds/1/sound.php"); etc etc I'm totally clueless as to how I might acheive it, especially including the "dividers" every two includes. Surely one of you clever folk gotta be able to spoon feed it to me? ;)
Exploding Text File....
I want to put a text file into a form field, and then submit it to a page that will split up the text file on two criteria and then loop through each split result inserting new db records. A sample text file would be: question 1;option1;option2l;option3 question 2;option1;option2l;option3 question 3;option1;option2l;option3 I need to split it on blank lines and then again on the options so that my insert would be insert questionname, option1, option 2....into questions. Can someone help please. I know I can use explode, but unless I am missing something then its just not working for me.
Exploding Tab Delimited Line
I'm trying to create an array from a tab delimited line of text. I've tried explode('/t',$line); but doesn't seem to work. What am I doing wrong?
Imploding/exploding 2 Dimensional Arrays
I am using this to explode an array that has been imploded and passed via an invisible field... //REMAKE THE LIST ARRAY $list = explode('|',$stringlist); //COPY AND NAME THE FILE $address = "../../projects/img".$count.".jpeg"; copy($file, $address) or die("Couldn't copy the file!"); //GET TITLE NAME OF IMAGE $position = strpos($file_name, "."); $file_name = substr($file_name, 0, $position); //ADD THE FILES NAME AND ADDRESS TO LIST $temp[$file_name]=$address; $list[$count]=$temp; $count++; its for a file uploading system and i want to build a 2 dimensional array of the original names of the file and the url it will be stored at, what i cant figure out is how to correctly implode a 2 dimensional array so that it will pass correctly, here the first file gets submitted correctly but while doing the second file 'array' gets passed. can someone show me how to implode and explode a 2 dimensional array or point me to where i can find info on this.
Exploding String, Then Putting It In Array
I have a script that reads the files in a dir, then explodes each file name. The files look like this: Artist - Album I want the explode the characters before the " - " (the artist) so I can collect a list of artists without the album info. I'm trying to explode the filename and then have it pushed into an array but it's not working. PHP Code:
Exploding Results Of Mysql Query
I have a table with times and dates listed like this: 0000-00-00 00:00:00 2003-09-20 20:26:22 etc etc What I want is to query the DB for the field (matchdate) and then get it to explode the ' ' to give jsut the date for me and then put it into a dropdown in a loop. this may sound easy but i too sleepy to work it out and searching aint good.
Exploding Comma Separated In Array
I'm looking to explode the comma separated values in an array like this: Array ( => 10811 [1] => 7527,7556 ) and then add the exploded value as a new key in the array...like this: Array ( => 10811 [1] => 7527 [2] => 7556 )
Getting The REAL Directory?
Is there any way to get the directory/path of the file running the script, not the directory you're inside (Via dir())? I'm allowing the user to navigate through directories, and that part works great - but whenever I attempt to used getcwd(), it returns the directory the user is in - not the directory of the php file - is there any way to get the directory of the .php file the user is using?
Real-time Output?
I'm a relative PHP newbie, so I apologize if this is a simple question. Anyway, here's my problem. I'm using a PHP script to pre-render a bunchload of insert files for an HTML page. Right now there's about 1,600, but that number could get much, much higher when the site goes live. I'll only need to re-render the whole batch once or twice a year (if that) but it's still something I'd like to be able to do in case I have to move the site to a different server, or there's a hard drive crash or etc. Basically what the script does is grab a whole bunch of information from a database and write the insert file. It does this for every single one. The problem of course, is that PHP by default does all this server-side, and then sends it to the browser. Because this process takes like ten or twenty minutes to do, the browser times out long before it's finished. Is there a way to get progressive output with PHP? Or do I need to re-do this in another language like Perl?
Real Length Of Arrays
Sometimes, I want to know how many elements are really in an array (php3). The count() and sizeof() functions apparently return the number of non-empty array elements, and if you do a while loop checking for empty will stop on the first empty element. I have been using the following function: function truecount($theArray) { if (is_array($theArray)) { end($theArray); return key($theArray); } } but if the key is non-numeric, won't that trip me up? Anyone have a better solution?
Md5 / Sha1 - Any Real Difference?
I use md5 hash with some of my cookies and occassionally a hidden form field - I know the physical data on my network is insecure (unless being served via https) but I was wondering if there are any advantages to using md5 over sha1 or versa vicea... I know md5 gives me a unique 32bit hash while sha1 I've read is 'secure' (?) and gives a 40bit hash... Since The technical webpage on sha1 is lengthy and for the most part over my head... and other than today, I've never heard of it before... I was wondering if anyone could offer any comments on it...
Real Time Chat
There's anyone out there that can give me a light on real time chat using sockets. I've seen some using push technics but they all hang up after an elapsed amount of time.
Htmlspecialchars/real Escape
I'm creating a BBCode parser, and everything's working but one thing; I need code tags, but I will need to real_escape/htmlspecialchars the post to make sure it isn't malicious. The only problem is if I real_escape with code tags that contain php, the php will be removed. If I specialchars the post with php, I can't have syntax highlighting (or, not easily). How do I get round this?
Real IP Address From Behind Proxy Or NAT
How to get the real IP address of a user, not that of their proxy server or the external NAT address. I was quite sure that this wasn't possible without some kind of process getting the address on the client machine. I have suggested that these sites could be using Java to get the real IP address, however, I could be wrong and for me the script that I found always returns 127.0.0.1 . This suggests to me that any script attempting to obtain the hosts real IP address infarct rely s on the HTTP-X-FORWARDED-FOR header sent by the proxy server...
Real Audio Download Limiter
i'm running a site with .ra and .ram files, when some visitor download or stream all these files at the same time it causes an huge bandwidth consumption. so i'd like to limit the download per each IP to a certain number of .ra and .ram files at time. i wonder if i can use some php script with cookies session but i'm new to this and i don't know where to start.
Real Time Echo'ing Of Var In A Loop
i have a big loop, and rather then waiting until its done for me too see what happened, every time it runs, how can i get the browser to echo the result, and proceed to keep running the loop. basically this loop takes a long time to finish, and i had to set my max runtime past 30 seconds. i guess incorporating a refresh of some sort like this would eliminate the need for the time extension too?
PHP Template Redirecting To Real Video
I've developed a RealVideo content management system w/ PHP and MySQL. On the back end is a form that sends a Real Video file (.rm) and writes the filename to a database. On the front end is a PHP template that pulls the filename from the database and outputs a string that is read in by a Flash movie. The Flash movie reads in the file location and places HTML-encoded text inside a text field that says "Launch Video." All works fine -- the Flash movie launches the Real Video file, and the file plays correctly. There's only one problem: the Real Video doesn't stream. In order for a Real Server to stream a Real Video file, a "stub" file with the extension .ram needs to be placed in the root directory. The only content in these .ram files is a URL pointing to the actual .rm file, and it's written in this format: pnm://ra.domainName.com/realvideoFile.rm My problem: The form is sending a Real Video file and the receiving page is copying it to the server as well as inserting a record into my database, but it can't write a .ram file to the root directory because to do so I'd have to adjust permissions accordingly (PHP is part of group Apache). That's unacceptable; I won't adjust permissions on the root directory. My solution was to create a redirector that acts as the stub file: PHP Code:
Real World Singleton Class Example?
Anybody can show me real world singleton class example? Something that works (is implemented) as part of working solution. Does it make sense to create database handler class that way?
Is Gmail Homepage Real Ajax?
I saw gmail's storage size on mail.google.com. It was counting size like "Over 2728.845439 megabytes". then increasing... but my dialup connection disconnected I don't understand howto count storage size, when my pc disconnected internet. is it real 2728.845439 MB? or only text?
Stripping Commas From Real Numbers
I have an HTML form in a PHP script which queries the user for a dollar amount of sales. If a user enters "1,000,000" rather than "1000000" for 1 million, PHP (or MySQL?) treats the commas as a decimal and "1" is entered in the database. A simple work-around is to simply advise the user "Please enter numbers only, no commas or $'s" but this seems awkward. Is there a built in function or another easy way to have commas and currency signs stripped out of form-entered data?
How Convert Http:// Text To Real Hyperlink?
I have some texts in MySQL databases. When I show this texts in webpages using PHP, I need to convert every ocurrence of http://blablabla.com to <a href='http://blablabla.com'>http://blablabla.com</a> , so my text will really became 'active'. The people who wrote the texts don't know HTML tags so I can't ask them to write explicity <a...> </a> commands. The problem is the same with text that contains the @ charactere, as name@mailserver.com . I have to change this to <a href='mailto:name@mailserver.com'>name@mailserver.com</a>. Please, I don't know how to use regular expression. I think It can make this replacemments very easy..
Checking If Email Address Is Live And Real?
There's all kinds of ways to validate an email address to make sure it's well formed and whatnot, but what about checking to see if it's a valid e-mail account? Like how you can use checkdnsrr() to check to see if a URL is valid. I know finger used to be used at one time, no? But server block finger requests, and I'm not sure many e-mail accounts out there are even fingerable type accounts anyway.
MySQL Result To Real Array In Function
I'd like to create a function which input is the result of a mySQL query. The output should be exactly the same, only not a mySQL result array, but a 'real' array. So it should also get the fieldnames returned by mySQL and use those as keys. I can't get things to work properly: it should return a multidimensional array, like $result_array[1] = array( [field1] => field1 value, [field2] => field2 value, etc. ) somehow my result is (with code below) $result_array[1] = array( [0] => field1 value, [field1] => field1 value, [1] => field2 value, [field2] => field2 value, etc. ) +++++ code ++++++ $get_res= mysql_query(QUERY); if( $res = mysql_fetch_array( $get_res ) ) { do{ $result[] = $res; }while( $res = mysql_fetch_array( $get_res ) ); }; foreach( $result as $key => $value ){ print_r($value); };
Real Good Content Management System ?
I'm getting somewhat annoyed about how many cms's there are in PHP/MySQL while so few are really good. Yesterday I started to like ezPublish, until I decided the template language is ugly and the process for creating a maintenance template for a content class is not logical. I'm starting to think I should write my own cms, but that will increase the leadtime for my site enormously. So I would like to know from you if you know a cms that .. - Is free and open source - Is PHP/MySQL based ( usable with just about any host ) - Doesn't enforce site/navigation structure - Has a WYSIWYG editor or one can easily be plugged in - Has a forum module - Is also an application framework with good separation of content, code and layout. - Does not have its own insane template language - Supports a moderation process for content - Has an intuitive process for creating maintenance forms for posting and maintaining content. I think Zope comes close, but that's Python :-(
Real Audio Http Streaming Without .ram File
I wanted a way to (http) stream Real Audio files without the need to use ..ram files. In case there are others interested in this, the following is the solution that worked for me: <?php Header("Content-Type: audio/x-pn-realaudio"); echo "http://www.domain.com/audiofolder/track1.rm"; ?>
Read Data From MS Access Into MySQL In Real-time
I am currently working on a project that involves reading information from a inventory system into Access via ODBC and display the info on the web site using MySQL. I would like to create a live link between the MS Access(local) and MySQL (remote) whenever the inventory system is updated MySQL will be updated as well. I know that MyODBC will let me do the opposite of what I would like to accomplish by reading data in MySQL into Access. Is it possible to do the reverse way.
How Can One Get Real Time Stock Quotes For An Online-community?
For one of our web-communities we plan an offer of real time stock quotes incl. advanced notification services. I have the following questions: - Do you know of any services, that already offers such services in a decent way? And more important: - Does anybody know a provider of such services, that offers a real-time stock quote data stream for such a usage at a decent price? I only know of Deutsche Börse offering it for 1駨 Euro per month. That is too expensive for us.
Dynamically Genetrate RAM (Real Media) Text Files
I am working on a record company's site. They offer a selection of track snippets for stream/download. I would like to be able to dynamically generate the RAM (text File) to save manual input in the DB. Currently each RAM file has to be uploaded everytime a new track is added....but I'd like to have this created on the fly when a user is browsing the site. user selects track...is forwarded to the dynamically generated RAM file...which in turn selects the appropriate media. I can't think how i'd get this to work as I am trying to create a text file that is parsed rather than a peice of HTML that is read by a user. Perhaps on the server I'd have to add PHP Parsing to the RAM mime type?
Line Breaks In PDF
I am trying to create PDF-s using PDFLIB. This works fine, as long as the printed text does not exceed one line. I cannot create a linebreak, so when I use the code below, the text seems to run of the screen.
Line Breaks
I've got in mysql table a TEXT field where I've got this contents: "This is a text" Now, I want to put this text into a javascript but than I need it convert it this way : "This is a text" Do you think this is possible?
(H) In Line Breaks
I have a cell phone with full internet access. I have an HTML page that I wrote specifically for use on my cell phone. It uses PHP's fopen() to open files on my server and then displays the contents of the file I opened using a <textarea>. This allows me to update my site from my cell phone. It works fine from a browser on my computer, but when I use it to open a file from my cell phone, all the line breaks are preceded by this character that looks like a copywrite symbol, but with an (H). Extended ASCII 233 according to http://www.asciitable.com . I write the pages in Dreamweaver MX initially, which gives me a few options about how to write line breaks (either for Linux, Windows, or Mac; CR, LF, CR LF) but I need my files to work on all three of my operating systems, since I use a Mac a home, a PC at school, and my server is Linux. I'm guessing that my computer is writing CR LF and my cell phone is interpreting it using a different character set where 233 means this (H) thing instead of CR. But how can I get rid of these characters? Possibly, could I use PHP to check the user-agent of the client to find out whether it's a cell phone, then replace all CRLFs with just LFs? And would I need to put them back in afterwards? If so, how?
Line Breaks
This questions relates to inserting data into a mysql database through a php interface that uses a normal html form... If I press return a couple times to make a new paragraph when filling out the text field, it never puts those line breaks into the database.. it always returns the data as one long paragraph.. How do I make it so that when a user presses return in the form, the output of data from the database knows there are supposed to be line breaks there??
Line Breaks Using PHP
I have a PHP script that I need debugging. Below is part of a script I have going. It bascially outputs what has been entered in the form field. Currently, it outputs a long line with no breaks. How can I add paragraph breaks after 25 words or so?
Line Breaks
I need to append a string of data as a new line in a static file. Basically what I'm doing is pulling IP's and adding them to htaccess as "not allowed". I start with a read file as append my master list (that has everything for the htaccess except the last line "allow from all"), append the string of data, then save/close that file. The problem is, everytime it is saved the line breaks are displayed as little "boxes" as demonstrated in this screenshot: This also happens when I simply copy a file that I know is displaying the line breaks correctly, and also if I simply RENAME a working file. All the line breaks get screwed up as those boxes! I know my code is working as I tried it on another PHP5 server running windows professional with apache 2. I've tried everything from string replace in dreamweaver by hitting the "enter" key as the item to replace inside double quotes, to opening the PHP file in notepad and copy/pasting that "box" as the thing to string replace. Incidentally, if I open the notepad file I just did that to in dreamweaver it displays the same way visually as if I hit the enter key (a lot of white space and the string is spread across two lines visually).. I've even tried force encoding the page as UTF-8 but nothing seems to work. All the output displays as a single line of code. It APPEARS to work if I output the file as an html file and view it with my browser, but this is useless as a view-source shows a single line of garbled text still. It appears this is some type of server setup issue and I don't know what to do. I'm running PHP5 with mysql4 on a Plesk 8.0 redhat server.
Line Breaks
How do i retain paragraph breaks when inserted into a sql database through a text field without the user having to manually input tags??
Text Box Breaks?
i have a simple code that echo's text within a textbox after submit. but it just puts it all together, it dosn't keep the lines! like if the person pressed "Enter" like 4 times it wouldn't matter, it just puts it into 1 jumble. how do i fix that? <form method="post"> <textarea id="text1" name="text1" rows="10" cols="30"></textarea> <input name="add" type="submit" id="add" value="Add"> </form> <?php if(isset($_POST['add'])) { $text1 = $_POST['text1']; $text2 = htmlentities($text1); echo $text2; } ?>
Line Breaks
I am having some trouble with converting html code to real line breaks in a textarea, I have the following code that I gets html code from a database and then puts it into a textarea but the str_replace I am using converts the text but puts the actual characters in the textarea, and doesn't actually turn it into a linebreak. (the br below is reality in triangular brackets!) $paragraph=$row['paragraph']; $paragraph=str_replace('br',' ',$paragraph); ..... <textarea name="ud_text" cols="50" rows="15" maxlength="300"><? echo $paragraph ?></textarea> Perhaps someone can help me with this?
Converting Line Breaks To <br /> And <p> </p>
I'm working on a blogging platform, and I'm struggling with the final output (what the end users/web visitor sees). I've got to the stage where the data stored in the database in 100% correct. My problem is converting line breaks to <br /> and <p></p>. An example database stored entry: <h2>A Testing title!</h2> A list: <ul> <li>Item 1</li> <li>Item 2</li> <li>Item 3</li> </ul> Another paragraph. This is how I'd like it to be displayed to viewers: <h2>A Testing title!</h2> <p>A list:</p> <ul> <li>Item 1</li> <li>Item 2</li> <li>Item 3</li> </ul> <p>Another paragraph.</p> I've tried: nl2br and replacing double '<br />' to '</p><p>', but this messes up the HTML lists and sometimes H tags. What I really want is a nl2br function that doesn't work between block level elements.
|