#Find bug please

44 messages · Page 1 of 1 (latest)

clear wing
#

Please define the problem and not just give random code that noone can understand.

cerulean summit
#

sorry i defined the problem at the end of the message, i ll put it at start

kind plover
cerulean summit
#

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

kind plover
#

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

cerulean summit
#
{
    "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 ..

kind plover
#

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:

  1. Getting your string (which I am assuming is the authors and the title?)
  2. Separate the string, so that you have the title, and the list of authors, in two different string
  3. Further split the authors into separate strings, as appropriate
cerulean summit
#

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"

kind plover
#

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

#

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

cerulean summit
#

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

kind plover
#

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

cerulean summit
#

yes it should be, but that excel look like this

kind plover
# cerulean summit 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

cerulean summit
#

that xml file looks pretty good

#

if i could see it sooner, maybe i would use that instead of mine method but.. im almost done with this so

#

but thank you for your support bro

kind plover
#

It returns lists per-day

#

of XML items

#

properly formatted

#

They also have a list of persons to map against on that page