PHP - Php Line Separator And Length Character
Hi
I am running on Linux scripts with PHP and need help with separating my output on html screen to have different sections. This is my php info below
echo "<td bgcolor=\"#00B400\"><a href="$f3"><font size="2">$f1</font></td>" >> $PINGVAIL
Similar TutorialsHow can I test if a chunk exceeds the image size and wrap that text to the next line. Not sure if I am even doing this correctly with my if statement. $text="Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem http://somelongurl.com/then-we-make-it-super-long-with-some-more/ Lorem Ipsum Lorem Ipsum Lorem Ipsum http://www.anotherlinks.com/"; $string_chunks = explode(' ', $text); foreach ($string_chunks as $chunk) { if($end_x + $chunk > $image_width){ $start_x = 5; $start_y += 20; } $coords = imagettfbbox($fontsize, $angle, $font, $chunk); $end_x = $coords[0] + $coords[4] + 10; $color_to_draw = is_a_url($chunk) ? $linkcolor : $black; imagettftext($im, $fontsize, $angle, $start_x, $start_y, $color_to_draw, $font, $chunk); $start_x += $end_x; } With this code I get: Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem http://somelongurl.com/then-we-make-it-super-long-with-some-more/ Lorem Ipsum Lorem Ipsum Lorem Ipsum http://www.anotherlinks.com/ What I would like to happen is something like: Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem http://somelongurl.com/then-we -make-it-super-long-with-some-more/ Lorem Ipsum Lorem Ipsum Lorem Ipsum http://www.anotherlinks.com/ Hi guys, I have script which scraps content from web and writes it down in a text file, now everything seems to be okay. Its scraps and writes well but the problem is when i open that text file one weird character keeps coming after some words which i don't know about. I have attached the text file, will you guys please look at it and tell me how to replace that square looking character into new line in text file. Hi Guys,
How do i put a comma separator after a thousand ? Example if $grand28 was equal to 1234.00 how do i get it to read 1,234.00
here is my code " . sprintf("%.2f", $grand28) . "
I know the default length of a tiny int is less than an int, but if I put in the same length for both, are they essentially the same type? what im trying to do is take a youtube embed code find the URL code for that video and remove all other parts of the code keeping only the URL of the video after i get the URL by it self then replace the http://www.youtube.com/ part of the URL with http://i2.ytimg.com/vi/ to do this i know that i need something like this to get the URL of the video http://www.youtube.com/((?:v|cp)/[A-Za-z0-9\-_=]+) but how to only return just the URL is something idk how to do then use str_replace http://www.youtube.com/(?:v|cp)/" with http://i2.ytimg.com/vi/ so in the end im asking if anyone know how to remove all other codes i dont want and only keep the URL this may have to be done using "regex" im not sure as i dont know to much about regex and what it can do but does sound like it would help lol Hi. I want a simple textbox, that when submited, will replace very every new line, with the <br> tag. What will happen, when it submits, it will take the contents of a textbox, add the <br> tag where a new line is suposed to be, and save the string to a MySQL Database. I think this is the easiest way of allowing a user to edit what appears on a website when logged in, but if there is a easier way, then please tell me. What I am trying to do, is a login page, and once logged in, you enter new text into the textbox, click submit, and on the website homepage, the main text will change to what was submitted. But if there is a new line, I think the only way in HTML to make one is to put a <br> tag, so I want the PHP to but that tag wherever there is a new line. Sorry if I am confusing, I am not that advanced at PHP, but I would be very happy if you could supply me with the correct code. Time is running out... If you do not understand me, please tell me -- PHPLeader (not) Dear All Good Day, i am new to PHP (a beautiful server side scripting language). i want to send a mail with line by line message i tried with different types like by placing the things in table and using <br /> but the thing is the tags are also visible in the message of the mail. Here is my code: $message1 = "Name :". $_REQUEST['name']."<br />"; $message1 .= "Surname :". $_REQUEST['surname']."<br />"; $message1 .= "Cellphone :". $_REQUEST['mobileno']."<br />"; $message1 .= "Telephone :". $_REQUEST['landno']."<br />"; $message1 .= "Fax :". $_REQUEST['fax']."<br />"; $message1 .= "Company :". $_REQUEST['company']."<br />"; $message1 .= "Email :". $_REQUEST['email']."<br />"; $message1 .= "Country :". $_REQUEST['country']."<br />"; $message1 .= "Enquity :". $_REQUEST['enquiry']."<br />"; $message1 .= "Date&Time :". $date."<br />"; For this code if try to print/echo it it is working fine it is displaying line by line, but using this variable ($message1) in the mail these <br /> are also visible. Can any one guide me to resolve(to remove these tags from the message part) this issue. Thanks in Advance. :confused: i have to read a single line from a csv, its a really big file and i only need one column.
i need the response to be a string ,i made a search and found the following code but i dont have any idea how to get a single line from a single string per run .
<?php $row = 1; //open the file if (($handle = fopen("file.csv", "r")) !== FALSE) { while (($data = fgetcsv($handle, 0, ",")) !== FALSE) { $num = count($data); echo "<p> $num fields in line $row: <br /></p>\n"; $row++; for ($c=0; $c < $num; $c++) { echo $data[$c] . "<br />\n"; } } fclose($handle); } ?> Edited by bores_escalovsk, 16 May 2014 - 06:38 PM. Is 40 characters long enough for an E-mail field? Debbie I've got an enormous page for a pretty complex process. I just posted some changes, and it stopped functioning. Through multiple tests, I determined there was no problem with the code; it was just becomes too large at a certain point. I've read about changing settings in the php.ini file, but I'm not exactly sure what to change or what to bump it up to to allow for this huge page. Here are some current settings that I'm guessing control this problem: Code: [Select] max_execution_time = 30 ; Maximum execution time of each script, in seconds max_input_time = 60 ; Maximum amount of time each script may spend parsing request data memory_limit = 8M ; Maximum amount of memory a script may consume (8MB) ; Maximum size of POST data that PHP will accept. post_max_size = 8M ; Maximum allowed size for uploaded files. upload_max_filesize = 2M Does anyone have any insight into what to change or what settings might allow for a larger page? Not sure which one of these settings controls my problem. Thanks, as always, for any help. Hi all,
The output of the following line of code where user is Jack1234
$user = filter_input(INPUT_POST, 'user', FILTER_SANITIZE_STRING);using var_dump is string 'Jack1234' (length=8)I would like to know if there is someway we can use/retrieve the length value of the string that is displayed in the output or verify the string length against it. Thanks. Howdy, I have a page on my site that displays events I have uploaded. Below is the code that displays the event title. I want to know if there is a simple way to limit the characters of the title that a view will see. For example, limiting the title to 10 characters. So, if I had an event titled "My awesome new event". You would see "My awesome..." Hope this makes sense. I'm not sure if you will need to see more of the code to help me, thank you! <a href ="event-description.php?eid=<?php echo $data->EventId?>"<span class="events-title"><?php echo $data->EventTitle ?> $file = 'includes/views.txt'; $f = fopen($file, 'w+'); $views = fread($f, filesize($file)); fwrite($f, $views+1); fclose($f); The contents of views.txt is: Code: [Select] 1 Why is it returning it needs to be greater than 0?...The file isn't empty. Hey there, need some help badly. I'm trying to get the size of the BLOB data in mysql. Did a search and there are like no tutorial on this. Only relevant info was from this page, at the far bottom, it just wrote this (below code). But the writer did not explain how to use it. SELECT OCTET_LENGTH(content) FROM BloBTest WHERE filename='myimage.png' I just give it a trial an error, wrote this, but did not work. $LENGTH = mysql_query("SELECT OCTET_LENGTH(blobdata) FROM thedatabase WHERE id = 'selected_id'"); echo $LENGTH; Please help.... Hello everyone, I've searched these forums for a while now trying to resolve a problem that I have with my sessions timing out before I would like them to, but I've only gotten confused about it. I've read about changing some settings or adding code in my php.ini file but I have no idea what I'm doing when it comes to that. I'm starting the session simply by having session_start(); at the top of each of my pages. I'm including a copy of my entire php.ini file here so that you can see what I have already. Can someone please help me to figure out what I would need to do to make my sessions last at least 8 hours? Thanks in advance. Here's my php.ini file: Code: [Select] register_globals = off allow_url_fopen = off expose_php = Off max_input_time = 60 variables_order = "EGPCS" extension_dir = ./ upload_tmp_dir = /tmp precision = 12 SMTP = relay-hosting.secureserver.net url_rewriter.tags = "a=href,area=href,frame=src,input=src,form=,fieldset=" ; Only uncomment zend optimizer lines if your application requires Zend Optimizer support ;[Zend] ;zend_optimizer.optimization_level=15 ;zend_extension_manager.optimizer=/usr/local/Zend/lib/Optimizer-3.3.3 ;zend_extension_manager.optimizer_ts=/usr/local/Zend/lib/Optimizer_TS-3.3.3 ;zend_extension=/usr/local/Zend/lib/Optimizer-3.3.3/ZendExtensionManager.so ;zend_extension_ts=/usr/local/Zend/lib/Optimizer_TS-3.3.3/ZendExtensionManager_TS.so ; -- Be very careful to not to disable a function which might be needed! ; -- Uncomment the following lines to increase the security of your PHP site. ;disable_functions = "highlight_file,ini_alter,ini_restore,openlog,passthru, ; phpinfo, exec, system, dl, fsockopen, set_time_limit, ; popen, proc_open, proc_nice,shell_exec,show_source,symlink" For PHP 7.4, what is the recommended session length that I should be using to have the best security? In DEV< in my php.ini file, session.sid_length = 26 According to the comments above that, it sounds like you can go up to 256. Is it fair to assume that larger is more secure? Also, if I set it to a larger size like 256, is tehre any risk of breaking things on my (VPS) web server running WHM/cPanel? im trying to update a GPS table for example: UPDATE markers SET lat = '38.40907441955112' AND lng = '14.943452775478363' WHERE ApID = '35911' i tried with float 20,18 it isnt updatng correctly When a user logs on, I authenticate them with a session. How do I use php to determine the time until the session will expire? I realize I could go into the ini file but is there a php code that can query this info and echo it back? I am trying to figure out a way of filtering certain words from a string using str_replace - However i would like to replace the words with something showing the correct length of the word. So far I have got: Code: [Select] <?php $input = "Oranges, apples, and pears are all types of fruit!"; $words = array("oranges","apples","pears"); function convertType($x) { $maskWords = array(); $convertChar = "*"; for ($i = 0; $i < strlen($x); $i++) { array_push($maskWords, $convertChar); } $convertString = implode(".", $maskWords); $stripString = str_replace(".", "", $convertString); return $stripString; } for ($i = 0; $i < count($words); $i++) { $input = str_ireplace($words[$i], convertType($words[$i]), $input); } print $input; ?> As I am fairly new to PHP I am not sure if this is the most effiicent way of doing this so I was hoping somebody could provide some input for me. For instance is there a function to convert the array into a full-length string without using a delimiter? Thanks! Hi all, Yesterday I moved a web application from a normal cookie session to a use_trans_sid session because some users' browser didn't accept cookies. This works great, but the session used to last for 45 minutes (set with session.gc_maxlifetime), but after the change the session times out faster. (How) can I set the session length if I use use_trans_sid? Thanks, Base PS: PHP version 5.2.13-1 |