last day (191 days later) » 

9:34 AM
0
Q: Changing array values in PHP

GrischaI need to change some array values in a 2-dimensional array for some cases. Sometimes the all values from an child array and sometimes only some values. In this cases I should only change the variable $stamm which $stamm2. This code is the statement of an if condition, where all relevant verbs f...

 
Please provide a more context on the problem you are trying to solve and what values are in $array, $stamm and $stamm2.
 
@Nobody I have edited my question.
 
It is still missing the variable $array. To make it more clear: Preferably your code should be runnable as is. As far as I can see you should provide example values for $array and $verb and would be fine.
 
@Nobody Their is also an array_walk function to combine $array and $stamm. The code is workung for both versions.
 
You are still missing an example value for $verb and the overall description of what you are trying to do. My assumption is: You are trying to build a function that gives all possible inflections of a given verb according to french language. Is that right?
 
9:34 AM
Yes, you are right and I have add an example for $verb "For this example you could use 'acheter'".
 
So?
 
Hello, do you speak german?
 
Yes, but I think it would be rude to converse in german here because it cuts of other users
 
Ok, I thought it would be ok in a chat.
 
I am not sure about that
 
9:40 AM
If my second solution is the best way I could delete my question.
 
please dont delete questions
they are there to educate people
I am about to write up an answer/review for your code
but I thought you had something to discuss (hence the chat)?
 
only if you had another questions.
I have already many such array-changings and I want to improve all excetions cases.
 
Btw: I asked around in the main chat and it seems we can decide on the language to use in rooms that we created on our own
 
I understand english much better, than writting it ;-)
 
Well if it is not too much of a hassle than stick to it. It will help you and others to communicate :)
 
10:39 AM
OK
 
Why is it that you think you cannot change your code?
Maybe you should post the surrounding code
 
I don't have enough skills. I am glad for using now the foreach loop ;-)
 
Well, you can try and learn and you can post your code here for review
 
here in the chat? I could post some main files of the script.
 
no I mean here on Code Review
your already existing question can definitely profit from more context
so you could post your code there
 
10:45 AM
it has soo many lines and files ...
 
the next thing I would want to see would be the code that calls what you have posted already
 
I could give you a FTP access.
 
while I am willing to review it should be public
this means you should post the code in your question instead of handing out FTP access to single persons
 
My code is "very illegible and unstructured" like someone else reviewed it ;-(
 
Well, then this is your chance to learn what to change about it to improve it :)
 
10:48 AM
I send you 3 files via pastebin.com,ok?
 
you can do that and we will evaluate what of them to put into the question, okay?
 
konjugator.php pastebin.com/f1txQBX4
unregelmaessige.php pastebin.com/G2kkTHjf
index.php pastebin.com/XJREJgWB someone who helped me, created a htaccess file for showing pages for every verb thinks.
 
okay
I think your question is about the creation of the words and not about printing, so we could leave out those functions
 
Another problem is that all verbs (over 25.000) are in one array and for the translation (only infinitve form) I have another array/file ...
If we changing the creation of the words, maybe the printing have to changed also?
 
If so than that is bad design (I believe)
 
10:59 AM
I think it is a bad design ;-)
 
I am not sure how tightly the printing output is coupled to the creation process
 
and it is a lot of code to wrap ones head around
the printing should definitely be separated by use of a template system
 
What is a template system exactly?
 
In a template system you define the structure of the site independently of the content
you only have placeholders where the contents should be put
when the page gets visited the system fills those placeholders with the actual content
Eine Template-Engine (von engl. Vorlage bzw. Schablone und Maschine) ist eine Software, die eine Vorlagen-Datei (engl. Template) verarbeitet und bestimmte Platzhalter darin ähnlich wie bei einem Formular durch jeweils aktuelle Inhalte ersetzt. Die Bezeichnungen Template-Klasse (dt. ugs. „Vorlagenklasse“, aber sachlich korrekt: „Klassenvorlage“) und Template-System werden oft als Synonym für eine Template-Engine verwendet. Klassen-Templates in der C++-Programmierung sind dagegen nicht mit Template-Engines vergleichbar, weil sie eine vom Datentyp unabhängige Programmierung ermöglichen und ganze Klassen…
 
11:05 AM
and what is the difference between this and my function printIt ?
 
the difference is that the code is not intermingled with the representation
which makes both of the hard to read
as the wiki article describes, PHP naturally has the ability to do this
but it can be misused
 
I think I can only take the function printIt in an seperate file, but this isn't the solution,right?
 
solution for what?
I am currently skimming over konjugator.php
to see what needs to be put into the question
 
ok, sorry I don't wanted to interrupt you (solution for "printing should definitely be separated by use of a template system")
 
no problem, you did not interrupt me
the problem is: there is so much that can be done with this code, it would need to be spread over mutliple questions
and I am not sure where to start
I would separate the printing from the rest and make it an own question
 
11:21 AM
Why should I ask everything via questions? I think I haven't the ability to fulfill the suggestions.
 
Since you posted here on Codereview I assume that you care about your code's quality
your question was like: Is version B better then version A
this restricts how far you can improve your code to the limits of your own imagination, so to say :)
more eyes, more ideas
are you willing to learn new things?
 
Well, programming is for me like learning languages like chinese ...
 
... interesting? :)
 
I thought my only solution for this is finding someone, who could rewrite the code for a firm price, which I could pay.
 
so you went here to find someone like this?
 
11:29 AM
Yes, I'm interesting. I started 2002 my website without any knowledge about HTML,CSS and PHP.
I think I have not other solutions then try to do it by my own, because I can't find someone like this.
 
So you need to improve your skills to rewrite the code on your own?
 
sure
 
What was your expectation when posting here on CR?
 
I don't thought about the whole code, only for this little part.
 
Okay, and why do you want to change the code?
 
11:36 AM
I want a nearly perfect script, before I will use most parts of it for another language like spain.
 
Okay what does perfect mean in your eyes?
 
Unfortunately I have to write the same 2 if condition for a exception, because it won't work right else.
 
So you want to write only one
 
perfect means with all the suggestion from you, someone via mail and the other guy, who told me about "very illegible and unstructured", he said I should 1. format my code, 2. rewrite it and 3. write it in OOP style.
Yes, I want write only one, but I can't change $passe right in unregelmaessige.php
 
@Grischa that is a pretty good summary of what to do
@Grischa that is probably a problem because your code is unstructured
as I see it now there are several problems: you have old working code that is hard to maintain/extend
you lack skills to do the rewrite on your own
and you probably don't want to start from scratch, learning while going
 
11:48 AM
Thank you very much for your help. "learning while going" is my main principle.
 
is the starting from scratch part correct?
 
sure ;-)
I don't have the imaginary, how it should be
 
now I am unsure if I misunderstood: do you really want to start the code from scratch?
 
Do you think it is impossible to find someone, whom I could pay asmall price, which I could afford to work with together?
 
It probably depends
the price will most probably rise with the skill of the person
and I neither know how much you can afford nor how much people would take
 
11:59 AM
Did you could tell a price, you would do it?
 
I would not consider myself proficient enough to do so and even then I would not have the time
 
consider codementor.io
 
Nice one @rolfl, I totally forgot that this exists
 
12:18 PM
The prices only for 15minutes are very expensive @ codementor.io
 
@Grischa: Professionals cost money
 
Is their a similar site for students, who aren't such a professionals?
 
I don't know of any but if there were one I would be cautious because you don't know the skillset of the mentor
CR already offers you many benefits without the cost
so long as you are willing to publicly discuss your code
The only problem with CR in this regard is that changes can only be made incremental because the scope of the rewrite is too big
@Grischa Oh and btw: Don't accept so fast, it deters others from answering who might have more to say and better solutions
 
12:44 PM
ok
 
12:57 PM
I have to get some things done now.
If you want to rework your code with the help of codereview I would be willing to help you decide where to start/which questions to ask
 

  last day (191 days later) »