#Find bug please
44 messages · Page 1 of 1 (latest)
sorry i defined the problem at the end of the message, i ll put it at start
You've said you have an issue, but you haven't given any evidence of it happening
You said that in "meno" there is also text of "nazov prace", but it's not in the array you shared...
"nazov_prace" is another array key that you've defined in the code further up
Not sure what you're expecting?
meno should be only Horička, Pavol .. but instead it have value of ''nazov_prace'' before that
and i dont know how to fix that
Look at your code
You You're setting
meno to a trimmed/replaced textBeforeAuthor, earlier on in your code
nazov_prace, you're setting to everything before the first "/" in textBeforeAuthor
do you want meno to be "Horicka, Pavol"?
Share what you'd EXPECT it to do, i.e. what should that screenshot look like, for future reference, please don't use screenshots, it's very difficult to help when you do that, wrap the code in three ` marks either side
{
"publikacie": [
{
"nazov_prace": "Pick & Roll .Technika, taktika, tréning ",
"autori": [
{
"meno": "Horička, Pavol",
"podiel": "50%"
},
{
"meno": "; Jansen, Jan Willem",
"podiel": "50%"
}
]
}
]
}```
i expect this output
sorry im newbie in php and part of my code is also generated by ai so ..
You've done:
$nazov_autor_split = explode('/', trim($textBeforeAuthor));
$publikacia['nazov_prace'] = $nazov_autor_split[0];
So you know how to split $textBeforeAuthor by the "/"
If you want the bit AFTER the /, then it's here:
$nazov_autor_split[1]
The problem you've got, is that you're a bit all over the place with what you're doing to be honest
You're mixing things up a bit too much
What's the original string that you're trying to convert here
I'd suggest that you start by:
- Getting your string (which I am assuming is the authors and the title?)
- Separate the string, so that you have the title, and the list of authors, in two different string
- Further split the authors into separate strings, as appropriate
this is example of original array, what i need to convert .. i know my code is kinda messed up but i dont know how to move with that
{
"id_publikacie": 475430,
"nazov": "Pick & Roll .Technika, taktika, tréning",
"zaznam": "Pick & Roll .Technika, taktika, tréning [elektronický dokument] [iný] / Horička, Pavol [Autor, UKFPFAKTV, 50%] ; Jansen, Jan Willem [Autor, 50%]. – 1. vyd. – Nitra (Slovensko) : Univerzita Konštantína Filozofa v Nitre, 2022. – 140 s. [online] : text. – [slovenčina]. – [OV 210]. – [ŠO 7418] ",
"link": "https://app.crepc.sk/?fn=detailBiblioForm&sid=617ABF3FA69290793434871CBB"
}```
i need to get all authors and their %, also with "nazov"
Right, but you have "nazov", which you then set to "nazov_prace", why are you not just setting this at the top of your code:
$publikacia['nazov_prace'] = $zaznam['nazov'];
Now, strip $zaznam['nazov'] from $zanam['zaznam'], as you don't need that in there.
Next strip off the bit with 'elektronický dokument|textový dokument|iný' (like you've been done here:
$textBeforeAuthor = preg_replace('/\[(elektronický dokument|textový dokument|iný)[^\]]*\]/', '', $textBeforeAuthor);
Now you've ot a list of authors
But frankly
the app.crepc.sk site publishes XML formatted data
Such as the following (for the record you're referencing)
Why are you not using that?
They give you an XML document with all the data you need, in the format you need it
It has the author IDs in it
They also publish a list of who that author ID maps to
i cannot use that xml bcs this webapp need to be dynamic.. when "client" export all publications to one excel and pass it to this webapp, it should dynamically import to local db .. but i think i understand what you mean in your previous message
i ll try to fix that and let you know in few mins
If you have an Excel document
then it's even easier
crepc.sk has defined formats for their douments
documents*
don't waste your time, mucking about, trying to parse a string in a hit/miss manner
yes it should be, but that excel look like this
Yes, and they give you an XML version too
<title title_type="title_proper" lang="slo">Pick & Roll .Technika, taktika, tréning</title>
<cross_biblio_person role="author" ratio="50" alter_person_cnt="0">
<rec_person id="110638"/>
<affiliation bond_type="on_record" cross_id="214217">
<rec_institution id="26446"/>
</affiliation>
<authors_sheets/>
</cross_biblio_person>
<cross_biblio_person role="author" ratio="50" alter_person_cnt="0">
<rec_person id="551737"/>
<affiliation bond_type="unknown">
<rec_institution id="1"/>
</affiliation>
<authors_sheets/>
</cross_biblio_person>
But yeah, you are on the right track with your code, you just need to refine it a bit more, personally, I'd just use the RSS feeds from that website, rather than worrying about various files