Programming › Re: Need Help On This Basic Php by paranorman(op): 8:52am On Feb 22, 2016 |
|
Programming › Re: Need Help On This Basic Php by paranorman(op): 1:36pm On Feb 21, 2016 |
dhtml18: ^^^I am not thinking anything on this one, you need to provide a justifiable reason why you want to do something that PHP has provided functions for. Maybe you are solving a quiz somewhere, or have got the whole thing wrong. Your approach of the matter is unconventional and a sheer waste of time, i have provided the only code i am going to. . . .am waiting for you to solve it yourself. okay bro, when using PC, post it I shall. |
Programming › Re: Need Help On This Basic Php by paranorman(op): 11:21am On Feb 21, 2016 |
dhtml18: Na you go solve your problem yourself, when you have solve it, bring the solution here. . . . . hehehehehe.. When I get on PC, I will post here. Bros, you self think am na |
Programming › Re: Need Help On This Basic Php by paranorman(op): 7:51am On Feb 21, 2016 |
ChinenyeN: For the record, a call to file_get_contents is equivalent to calling fopen, fread and fclose, and according to the PHP manual, it is similar to the file function, except that file_get_contents returns the contents as a string. So you can assign it to a variable and do any sort of string manipulation with it. file_get_contents is not an extension of file, both have different return values (file returns an array). If anything, both file_get_contents and file are wrappers for or extensions of the main file IO functions in PHP (i.e. fopen, fread, fwrite, fclose).
Anyway, if all you're looking to do string manipulation, then file_get_contents is the functionality you want to use. It will give you the file contents as a string and you can do what you want. Once you're done, call file_put_contents (which is equivalent to calling fopen, fwrite and fclose), if you need to save the changes, just as in the example provided by dhtml18. hey, boss I tink I am talking too program contextual than program literal. Okay, file pointer should return an arrray, not string. Do not use functions that has got the word 'file' innit ( like file(), readfile(), file_get_contents() e.t.c...) you feel me? So understand me bros, dhtml18, |
Programming › Re: Need Help On This Basic Php by paranorman(op): 8:39pm On Feb 20, 2016 |
dhtml18: Use a database bro, this your line of programming reasoning is not normal. If I know the aim of your task, and the objective, maybe I can help you. But as far as i am concerned, you are talking in riddles.
Even if you use fopen, and you manipulate the file, you still need to save it. What you are asking for to me does not really make sense - whether in PHP or any other language. We need to understand precisely what you are trying to achieve, maybe we can help you. . . .
THERE IS NO WAY IN ANY PROGRAMMING LANGUAGE, that you can change the content of an existing file without overwriting it to save changes. Even databases sef at some level use files to save the contents of the database - it does not use magic. sorry I got you guys mistaken.. What I am trying to archieve here is writing a code that changes your string of interest only.( a fraction of your strings without having to work on the whole strings and then modify your string of interest? You dig? for example dhtml18, the code you wrote at first only worked on that particular string. You get what I am saying? You modified the particular string("alex"  only. I think I abused the 'overwrite' word, so it got you all confused. So, instead of using the file() function or any extension of it, use fopen and its companions and work on "alex" only.. You talking dbms, i know. I could use that. But this is just one little challenge. Ain't nothing serious. Just trying to avoid the file() functions and its extensions |
Programming › Re: Need Help On This Basic Php by paranorman(op): 3:16pm On Feb 20, 2016 |
asalimpo: You read the file into memory, change its content save changes to disk - how dyu do this without overwriting the file? It's impossible. I don't need to google squat. Maybe, all you're interested in,is maintaining the time stamp on the file. So that after overwriting content, the stamp remains unchanged. okay then.. Can I get your version of the code? Don't use the file() or any extention of it to load the file itself into memory. |
Programming › Re: Need Help On This Basic Php by paranorman(op): 1:23pm On Feb 20, 2016 |
asalimpo: sorry bro but you have to overwrite the whole file to save your changes. nope bro, you don't have to. Do a google search on that and you'd see some cool things. Thing is, I am not satisfied. |
Programming › Re: Need Help On This Basic Php by paranorman(op): 11:15am On Feb 20, 2016 |
dhtml18: Analyze this. . . i know this one too bro. Done it. But's still uses an extended file() function. I am talking....: fopen while (!feof..) fgets ..i used these, but the code is unnessarily long and uses lots of manipulations and overwrites the whole file. You can do better. |
Programming › Re: Need Help On This Basic Php by paranorman(op): 10:18am On Feb 20, 2016 |
Oya na |
Programming › Need Help On This Basic Php by paranorman(op): 10:17am On Feb 20, 2016 |
Let's say I have a 'names.txt' file containing:
john;jack james;jill alex;wellington
each line contains surname and first-name delimited by a semcolon, each line is escaped by \n.
Say I want to modify 'alex', how can I do this without overwriting the whole file itself?
I want a code memory friendly, so don't use file() function. Don't overwrite the whole text file, just modify your string of interest.
Cc: dhtml18 |
Business › Re: Myths About Naira Devaluation - Nonso Obikili by paranorman(m): 8:18pm On Feb 16, 2016 |
Topeakintola: On imports you mean?
I do understand your skepticism. Japan embarked on a series of devaluation of the Yen in other to make its exports cheaper, while that policy worked, it created another problem. It led to stagnation in the domestic economy and they have not recovered after so many years. Right now, the Japanese economy is bleeding heavily and its market suffering losses in value
On the other hand, in theory, devaluation can help to stimulate the export economy, my problem is how it is managed in Nigeria. good argument. The question is: has/can anything been/be properly managed in country(by government)? We play politics with almost everything. I just tire. I don't support devaluation, no! |
Programming › Re: Need Help With This Basic Php by paranorman(m): 5:17pm On Feb 13, 2016 |
dhtml18: I dey look all these codes and fear dey catch me? na basic code be this one na, noting pro at all. Na you be baba na |
Programming › Re: Need Help With This Basic Php by paranorman(m): 9:07am On Feb 13, 2016 |
dhtml18: Oga o bros, wetin happen na? |
Programming › Re: Need Help With This Basic Php by paranorman(m): 2:11am On Feb 13, 2016*. Modified: 3:09am On Feb 13, 2016 |
//roll the die and create a session variable for it //create another '$count' session variable to manage pesistence - that is, the number //of trials till you make a right guess //main program control logic; I call him Jarvis function jarvis() { if (!isset($_SESSION["die"])) { $die = rand(1, 6); $_SESSION["die"] = $die; $_SESSION["count"] = 0; print <<<here <h1>Welcome Dude</h1> <p> A die was rolled, try to guess the value, okay? Good luck. </p> <form action = "" method = "post"> <button type = "submit"> continue </button> </form> here; } else { ultron(); } //end main logic if } //end jarvis //I love this main function, reminds me of Ultron function ultron() { $dice = $_SESSION["die"]; //$dice is just the session variable 'container' $guess = filter_input(INPUT_POST, 'guess' ) ; $count = $_SESSION["count"]; //you wouldn't want $_SESSION["count"] 'naked', would you? //print "<p>die: $dice</p>"; if ($guess == null) { print "<h1>Die rolled, make a guess - already!</h1>"; } else if ($guess > $dice) { $count++; print "<h1>Greater than, try again</h1>"; } else if ($guess < $dice) { $count++; print "<h1>Lesser than, try again</h1>"; } else if ($guess == $dice) { print "<h1>Weldone skipper, you guessed right!</h1>"; //print "<p>count: $count</p>"; if ($count > 1) { print "<div>.. but it took you $count times to get it right</div>"; } //end $count if } //end if //print "<p>$count</p>"; print <<<HERE <form action = "" method = "post"> <fieldset> <legend>Make the guess</legend> <input type = "text" name = "guess"/> <button type = "submit"> submit </button> </fieldset> </form> HERE; //keep the session variables 'alive'! $_SESSION["die"] = $dice; $_SESSION["count"] = $count; //kill 'em off if objective is accomplished if ($guess == $dice) { unset($_SESSION["count"]); unset($_SESSION["die"]); print "<p><a href = \"dieGuesser.php\">Start game again</a>, or click the submit button.</p>"; } } //end ultron //initiate jarvis jarvis(); //forgive me, Ultron and Jarvis are friends in Paranorman's world
cc: hollyfat |
Programming › Re: Need Help With This Basic Php by paranorman(m): 2:09am On Feb 13, 2016 |
hollyfat: Check very well, it's in the submit button <input type="submit" name="guess" value="Guess!"> you base a condition on a button?! I wouldn't do that though. |
Programming › Re: Need Help With This Basic Php by paranorman(m): 2:08am On Feb 13, 2016 |
tgmservice: try this guess = 0; $ die = rand(1,6); for($count = 1; $count <= 5; $count++){ if guess == 0{ echo "correct"; }break else{if count == 5{echo "game over";} without even trying it out, I know it won't work! |
|
Education › Re: Solve This Simple Maths by paranorman(m): 12:16pm On Jan 31, 2016 |
Tinkybabe: Paranorman!! Long time! You maths whiz  Compliments of the season. honestly, I admire you maths skills. That question you just solved, I hate its likes mehn.. Infact, I gotta do some 'quantifying' before solving such. How have you been? |
Education › Re: Solve This Simple Maths by paranorman(m): 11:58am On Jan 31, 2016 |
Tinkybabe: I'm sorry, just seeing the mention. Ans= 150
Let total work to be completed be X
It takes 75 men 10 hours to complete X/4 work in 90days
750 hrs x 90 = X/4 X =270,000 arbitrary unit
We have only (150- 90)days left to complete the work at 15 hours per person. If total no of people required to complete the remaining job is R Then
15R x 60 =3/4 X Note X =270,00
R = 225
Men to be added to previous is 225- 75 = 150 men
brilliant gurl! |
TV/Movies › Re: Nl Monikers Based On Movies by paranorman(m): 11:25am On Jan 25, 2016 |
*frowns* |
Programming › Re: Need Help With This Basic Php by paranorman(m): 8:31pm On Jan 22, 2016 |
hollyfat: Try this
<!DOCTYPE html> <html> <head> <title> Die </title> </head> <body> <?php session_start(); if (isset($_POST['guess'])) { //check if session is set for die
if (isset($_SESSION['die'])) { //check user answer if ($_POST['answer'] == $_SESSION['die']) { echo "<p>Thumbs up!, you guess right.</p>"; unset($_SESSION['die']); }else{ echo "<p>Incorrect Guess, please try again</p>"; } }else{ //roll the die again $die = rand(1,6); if ($_POST['answer'] == $die) { echo "<p>Thumbs up!, you guess right.</p>"; }else{ $_SESSION['die'] = $die; echo "<p>Incorrect Guess, please try again</p>"; } } } ?>
<form action="" method="post"> <label for="answer">Enter your guess</label> <input type="text" name="answer" id="answer" required /> <br> <input type="submit" name="guess" value="Guess!"> </form>
</body> </html>
oga, there is no object in the form with the name 'guess', //second line of your php code. |
Programming › Re: Why Are Nigerian Programmers So Dumb? by paranorman(m): 12:21pm On Jan 13, 2016 |
So, is it wrong learning to program in open source languages? I am a newbie, trying to perfect my skills in PHP/javascript before moving on something else. Someone should say something. |
Culture › Re: Can One Have Sex After Traditional Wedding? by paranorman(m): 7:53pm On Jan 11, 2016 |
I think so. If the family recognizes him as their inlaws and her father 'officially hands her over to him', her both wedding gives their blessings, you got eye witnesses and of course, all traditional requirements are fulfilled, you can. I am not even gonna wear western atires in my church wedding. Strictly trad. |
Nairaland General › Re: Dear Nairalanders: My Friend Wants To Borrow My Wedding Dress by paranorman(m): 10:11am On Jan 11, 2016 |
emmeyj: Is it right for me to borrow a friend my wedding dress for her own wedding too? Please I want to know what to do... nope! Nope!! Nope!!! Stand your ground dear. One should be delicate with such things jare. This is Nigeria where wickedness is the good. If it were the western world, nothing may be wrong with it. The fact that you asked about it makes it kinda wrong. It's YOUR WEDDING DRESS, don't share it with anyone. If your friend wants one, she can get/buy something cheap. |
Education › Re: Solve This Simple Maths by paranorman(m): 7:03pm On Jan 07, 2016 |
hopelink1: A contractor agreeing to finish a work in 150 days employed 75 men each working 10 hours daily. After 90 days, only 1/4 of the work was completed. Increasing the number of men by …………. each working now for 15 hours daily, the work can be completed in time. dude, the trick in solving this kinda question is to quantify the amount of work done or to be done yourself, if you cannot solve it straight. Say total work to be done is 10000kg. For 150 days, twil take (100000/150)kg per day. So, after 90 days, 1/4 of the work was done= 1/4(10000)kg=2500kg work/day = (2500/90)kg work/day/man = (2500/90)/75 work/day/man/hours=((2500/90)/75))/10= quantity of work that can be done per man for an hour. According to contract, (150-90) days left, work is to be completed in 60days. Work left to be done is 10000-2500; after you have found work/day/man/hours, calculate amount of work done by a man for 15 hours. Remember, new men will be added. From this info, you should to able to manipulate and get your answer. |
TV/Movies › Re: What Are Your Favorite Animated Movies by paranorman(m): 9:42am On Jan 06, 2016 |
PeinDanzo: Naruto Monster in paris Paranorman Dr seuss the lorax Legend of the guardians Rise of the guardians Epic Rio 1 nd 2 Ratatouille Flushed away Thundercats Batman: The brave and bold Monsters university Over the hedge Mulan
If u haven't watched the 1st 5 movies I listed, then u're rily missing, trust me! dude, stop mentioning abeg. Should have copyrighted my name since. |
Business › Re: CBN Cuts Bdcs’ Dollar Sales To $10,000 by paranorman(m): 6:19pm On Jan 05, 2016 |
Tochaigh: I have an article that proves emifiele a retard coming soon.
What many Nigerians don't know is that even though the central bank pegged the exchange rate, it's still spending billions of scarce forex defending that fixed rate, because if it doesn't the black market will destroy the CBN.
Exchange rate, pegged or free flowing will always be determined by demand and supply in an economy like Nigeria's. Useless policies on top of piles of useless policies.
Enough said. My article is loading. true, demand and supply interactions should always be allowed to play, and the effect of such play is well pronounced in advanced economies of the world. Oga, mention me when your article is finally ready.. |
Celebrities › Re: Pics: Beauty Is Not Enough: If Not, Why Are These Ex-beauty Queens Still Single? by paranorman(m): 8:02pm On Dec 27, 2015 |
Utchgirl: Dt's ur football age.
28yrs my fat ass ! You must be Sherlock Holmes, female version. How did you figure out her palmwinetapper/Muna identity? Checked her profile/topics, their themes reeks of some kinda despiration; there's a trend - she needs a man sorta. |
Crime › Re: Motorcycle Makes Our Escape Easy: Robbery Suspect (pictured) by paranorman(m): 9:44pm On Dec 16, 2015 |
ozy4christ: confession indeed FCT indeed!! hmmm am dedicating this to my better half, though not knowing where you are right now but am still waiting for uuuuuuuuuuuuuuu!!!!!!!
if u like quote me! Who cares where have you been all this while? I have been looing all over the whole green earth for you! *winks* |
Christianity Etc › Re: Christ's Return Is Imminent by paranorman(m): 10:44pm On Dec 13, 2015 |
Shalomdee: Brethren, by the revelation of God I received a vision some few months back that Christ returned and only one man made it, I asked God why HE didn't take me and He told me it was because I was filthy and had to sanctify myself, in reality and in the dream I had plaited wool on my hair and in the dream I knew it was because of it. Those putting on tatoos, make-up, artificial hair, bleaching cream, jewelries, e.t.c, beware of those things because they are sinful.
Please we have no time till Christ's return, do not reject His truth. If you haven't yet given your life to Christ, please do now. Invite Jesus to your heart and ask Him to forgive you and make you born again.
I sense strongly that five years is all we have left, the tribulation of the saints will occur before His Second Coming, Tim LaHaye's Left Behind doctrine is not at all correct.
Read 1Tess 5:1-28
God bless. God bless you sister. May God uphold you in His power, keep you in His bossoms, flourish you in spirit, mind, body and soul, keep you in His salvation, preserve you for his kingdom and worthy to be rapturable, amen. |
Jobs/Vacancies › Re: UBA Recruiting by paranorman(m): 12:42pm On Dec 07, 2015 |
|
Celebrities › Re: John Boyega: Nigerian Playing A Lead Role On Star Wars by paranorman(m): 5:20pm On Dec 06, 2015 |
pcguru1:
my dear forget about my comment please take time and watch Star Wars 1-6 it's the most beautiful thing ever, and am glad am alive to witness Star wars 7, please don't watch Clone wars we don't regard it as part of the star wars franchise. I have them all incase you want it, infact it's my Xmas tradition to perform the Star wars Marathon from morning to night, please dear watch it it's too beautiful bros, abeg, mail me all these movies na.. I beg of you. |