This is what I want to do: 1 sum all those values and give them to the first key which is [A.txt]. 2. remove the [A.txt] then sum [b.txt] and [C.txt] then give the value to key [B.txt]. 3 Remove [A.txt],[B.txt] then sum whatever is left and give it to [C.txt].
stanliwise: I am not clear of your code and looking at it I don't see how it would solve your problems.
The only thing to consider now is that your questions should not have what we call circular-reference.
So no file now must link to another file that link back to it self. you need a code to do that checking. that been said a simple pseudocode should do.
Please flip your phone horizontally to see the codes properly.
#check for circular reference and ensure none exist
it gives thesame answer as this code I posted before
#this stack will be a global variable to track all opened file and ensure it was not opened twice. $stack = [];
find_sum($file_path){ global $stack; $sum = 0; $values = [] fill $values with all the lines from $file_path
foreach($values as $a_value){
if (it is a number) { $sum += $a_value; } elseif( it is a file_path) { #check for circular references if($file_path is in $stack){ die('Error: Circular Reference Encountered'); } else { #add the file path to stack as already opened $stack[] = $a_value;
#use the recursion concept $sum += file_sum($a_value); } } }
stanliwise: I am not clear of your code and looking at it I don't see how it would solve your problems.
The only thing to consider now is that your questions should not have what we call circular-reference.
So no file now must link to another file that link back to it self. you need a code to do that checking. that been said a simple pseudocode should do.
Please flip your phone horizontally to see the codes properly.
#check for circular reference and ensure none exist
#this stack will be a global variable to track all opened file and ensure it was not opened twice. $stack = [];
find_sum($file_path){ global $stack; $sum = 0; $values = [] fill $values with all the lines from $file_path
foreach($values as $a_value){
if (it is a number) { $sum += $a_value; } elseif( it is a file_path) { #check for circular references if($file_path is in $stack){ die('Error: Circular Reference Encountered'); } else { #add the file path to stack as already opened $stack[] = $a_value;
#use the recursion concept $sum += file_sum($a_value); } } }
return $sum; }
I did something similar to this before, when i get home i will try yours. Thanks a lot i really appreciate it
Iambro: Create a recursive function that read the files or check if it is a directory then reads its files etc.
I have done that, it didn't give the desired answer..one thing is this question looks so easy but when you start to code then you will get hooked somewhere
Write a production-ready function in PHP that sums the numbers in a file and outputs details of the results. The function will receive as input the path to a single file. Each line of the file will contain either a number or a relative path to another file. For each file processed, output the file path and the sum of all of the numbers contained both directly in the file and in any of the sub files listed in the file (and their sub files, etc).
For example, if file A.txt contains:
3 19 B.txt 50
And file B.txt contains:
C.txt 27
And file C.txt contains:
10 2
Then the output of passing A.txt to the function might look something like this:
A.txt - 111 B.txt - 39 C.txt - 12
I have tried everything I can but it only shows result for the first file
Sewgon79: Sir you are right about Oduduwa having many children but the only FEMALE child Oduduwa have gave birth to is called "IYUNADE" which gave birth to the first King of Owu. OLOWU not OLUWO. The story of Oluwo is different. Iwo in Osun was created by son of First Female King of Ile Ife, Ooni Luwo Gbagida, who also happen to be the last Female Ooni. Who married one of her chief and give back to a son which can not lay claim to the throne and has to be sent seek "Ifa" help and went on journey to discover the town that is called Iwo Today. And he became the first King of Iwo being from Ile Ife dynasty.
I am sorry, you are not right on that of Iyunade. Do you know how old Owu is, why did you think that they used to say that Owu la koko da. She married Olowu, she didn't give birth to Olowu. Owu has been before Oduduwa was even born
FMAKJ: Ok, Okanbi has how many children? and where did they relocated to?
If you are ready to hear undiluted truth about the Yoruba, and ready to hear what you have never heard before then head to YouTube. Search for Tani Yoruba by Laji Abbas When I get to work i may help you look for the link to make things faster
modified start your learning from here. it will take you days to finish it though
FMAKJ: Im not pushing for oyo or anywhere, I am only saying things as they are and according to correct history.
Do you also know that Oranmiyan met some people in Binin called Igodomigodo. So, is not like there was nobody in Benin when he got there.
I am not talking about Bini, let's focus on the Oduduwa story you started. It is false, it was started to spite Ife. I have never seen an Ife indegine that says the okanbi story. Then when you even said that Okanbi gave birth to Ooni through a slave made me laugh. Did you know what the leader of Ife was called at that time before it became Ooni.
FMAKJ: I am not even from oyo. My own story is for another day which will surprise you. That oduduwa story falling from the sky is a lie. Lamurudu gave birth to Oduduwa,simple!
Now, do you know that Lamurudu met certain people in ife when he arrived?
Now, to give you a tip of where I come from, I am from that certain people lamurudu met in ife.
If you are from Ife then why are you pushing Oyo version of Oduduwa history, I am Still not surprised though because it is from Ife they push most of the lies we have in Yoruba land out even though they know the truth
FMAKJ: It was Okani the son of Oduduwa that has Eight children. Oranmiyan is the number 7 while Ooni is the number 8 via a slave woman and Ooni became the king after Okani passed away. Oranmiyan then went to Oyo and found Oyo.
I won't argue with you, it is the stories you hear people saying about that you accepted, and your version of Odudwa story shows you are likely to come from Oyo because they are the ones that started that version. I won't blame you though, I also believed the story of Oduduwa falling from the sky for many years
FMAKJ: Ok, do me a favour. Check the bronze head of the first king of warri (Ginuwa) and compare the face with the previous king of warri.
Please don't get me wrong o. Itsekiri is 95% Yoruba. Even the Royal family that came from Bini, in fact the royal family is still a combination of Ife and bini. So you are right on that one but the story of oduduwa uou wrote is not the true one, in fact Oduduwas children are so many, he also gave birth to females too. One of them is the mother of the founder of Iwo in Osun srate
FMAKJ: Do you know that the first king of warri is a generational son of one of the king of Benin, while the first king of Benin is called Ewaka 1, Ewaka dad is called Oranmiyan the 7th son of Okani, while Okani is the only son of Oduduwa.
By the way, Oduduwa dad is called Lamurudu.
Now you see how Delta,warri and yorubas are related.
Hmm this your history get as e be. Not really true
Oluolad86: Dear Lord please heal me now from pericarditis
I jsut prayed for you now. You are healed already. Be ready to type the testimony of your healing right now. Hold fast to Isaiah 53:5 Rejoice greatly because it is done and you will have the healing.
I will be waiting for your testimony thread tomorrow sister
zyphr: I have been in a relationship with my girlfriend since September 2019. I intend to marry her. The problem is that, I don't desire her sexually. Any intimate touch from her feels like the touch from a blood sister. Very uncomfortable. She is a strict Christian with a policy of no premarital sex. So we have never had sex except for occasional kissing and romance which I sometimes initiate. However, since January this year, I lost sexual attraction towards her and I avoid even simple touches. In fact, last Sunday we were walking down the street and when she placed her arms round my shoulder, I stylishly evaded it. I don't feel like this towards every other woman.
I'm currently not seeing any other lady but I have had sexual flings with two different ladies including an ex.
Question is: Is sexual attraction/desire neccesary for marriage? Is it normal not to feel sexually attracted to your partner? Can this be a basis for break up as I fear it might persist in marriage and make me cheat on her.
I am experiencing something similar too at the moment ,please if you found a solution kindly let me know
Arkmanbuddy: Only the naive and valueless coders will be edged out o the industry. The experienced ones who have been in the game for sometime will always make money more than the computer science graduates you're talking about. You think it's about degree and some stupid theories that are being taught in schools, the real coders don't need interviews for jobs, they know how they make their money.
Bro calm down nw, you don dey vex ni This is not a fight o, just stating the new trend now
I could remember some 10 years ago web developers were not considered or regarded as programmers, even here on nairaland there used to be a fight between web developers and computer science students. The fact that these web guys make more money even caused most CSE students/graduates to get angrier. This fight is not limited toNairalnd alone, it happens on almost any forum at that time.
Now it seems the science guys may be winning now as things have changed. Now if you didn't study computer science or Mathematics in the University you may find it difficult to cope during interview sessions and tests.
The term "Web developer" or "Coder" has been faced out gradually hence the word Software Engineer/Developer is in vogue now.
You need to be grounded now in Data structures, design patterns, algorithms, etc for you to fit in. If you didn't study computer science while in school you may find it hard to navigate your way, Then with the way the tech world is going so many branches are now been created eg DevOps and the likes.