Je souhaite diviser une phrase en un paragraphe et chaque paragraphe doit contenir moins de nombres de mots. Par exemple:Diviser les phrases en paragraphes en fonction du nombre de mots comptés
Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source.
Paragraph 1:
Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old.
Paragraph 2:
Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source.
Dans l'exemple ci-dessus, les mots moins de 20 est dans un paragraphe 1 et le repos sont sur le paragraphe 2.
Est-il possible d'y parvenir en utilisant php?
J'ai essayé $abc = explode(' ', $str, 20);
qui va stocker 20 mots dans un tableau puis le reste d'entre eux pour le tableau $ abc ['21 ']. Comment puis-je extraire des données du premier tableau 20 comme le premier paragraphe, puis le reste comme le deuxième paragraphe?
Votre dernier paragraphe: 'Je l'ai essayé ...' est complètement faux, s'il vous plaît reformuler. – Athafoud
vous pouvez essayer de convertir votre chaîne dans un tableau, puis stocker les 20 premiers caractères dans une chaîne et le reste dans un autre. – Aradhna
Il suffit d'utiliser 'implode' après' explode'ing votre phrase. http://stackoverflow.com/questions/5956610/how-to-select-first-10-words-of-a-sentence – TribalChief