请问如何将这段内容拆分为二维或者多维数组?

因为要实现分页,需要将内容按照每行区分,区分后,每页显示16行。大概分了5页。
自己拆分后,显示的都是字符串。搞了很久,搞不定,所以来请求大佬帮帮忙!

数据:

["“哼!平时道貌岸然的在我面前装矜","持,现在还不是任我摆布?”\n  ","男人猥琐作呕的声音夹杂着湿热的气","息,在苏幼宁的耳边响起,紧接着一","双油腻腻的手就在她身上游离摸索起","来,令得她下意识的想要挣扎。\n "," 苏幼宁头疼欲裂,恍惚间看到有人","压在她的身上,立时抬腿一记猛顶,","痛的他当即惨叫连连。\n  她从床","上迅速翻起,抓过旁边炕上扔着的破","抹布就塞进了他的嘴里,霉臭味熏的","男人连连恶心。\n  看着面前年轻","了十几岁的刘奎,苏幼宁有些愣住了","。\n  她迟疑的看向自己的手,纤","细白嫩,并没有那么多的老茧和伤疤","。\n  老天爷这是开眼了吗?居然","让她重生了?\n  脑海中的记忆如","同潮水般的复苏袭来,苏幼宁眸带恨","意的盯向床上痛的生死未卜的地痞。","\n  就是这一天,她的后娘和继妹","为了能抢走她的婚约,故意给她下了","药物还把刘奎这个地痞引了进来,毁","了她的清白。\n  而继妹更是带了","一帮人来捉奸,把她和衣衫不整的刘","奎当场抓获,无奈下她只能嫁给刘奎",",从此过上了生不如死的日子。\n "," 村里头的人更是见到她就吐唾沫,","大骂她“不知羞耻”、“狐狸精”,","她原本的婚约也落到了继妹苏月安的","身上。\n  苏幼宁心里的恨意翻腾",",还好,还好老天爷有眼,让她回到","了祸端开始的这天。\n  “刚刚你","骂的很开心是吗?”苏幼宁冷冷的看","着痛的满头大汗的刘奎,二话不说抓","过桌上的茶盏,当头砸了下去!\n "," 想到前世在刘奎这所受的苦楚,苏","幼宁恨不能砸死他才能解恨。\n  ","刘奎惊恐绝望的痛嚎着,但却根本无","济于事。\n  苏幼宁一脚踩在他的","小腹上,揪起他杂乱的头发,眸子冷","的几乎要杀人,“说,是谁让你来毁","了我的?是高氏还是苏月安?”\n "," 面对着如同罗刹恶鬼般的苏幼宁,","刘奎慌的连忙点头。\n  他没想到","这瘦弱的苏幼宁居然这么大力气,打","得他毫无还手之力,身体下面更是痛","的几乎快要爆炸。\n  “她们都有","参与是吗?”\n  刘奎又止不住的","点头,生怕这姑奶奶又来一脚。\n "," 他费劲拽掉了口中的臭抹布,一把","鼻涕一把泪的哭道:“姑奶奶啊,我","知道错了!我以后肯定不敢打你的主","意了,求你放过我吧!”\n  “放","过你?那谁来放过我?”苏幼宁冷笑","不止,她上辈子就是被这个男人毁了","终生。\n  她捡起地上的碎碗片在","刘奎的脖子上比划着,声音冷的刺骨",",“记着,今天来这里的人是苏月安",",不是苏幼宁,被你睡了占便宜的是","她,她的胸上有块月牙的胎记,记住","了没?”\n  “记得!记得!”刘","奎吓得三魂都没了七魄,缠着嗓音哭","道:“今天来这里被占便宜的人是苏","月安,她的胸上有块月牙胎记!”\n","  “三天内把这件事散扬出去,听","见没?”苏幼宁因为干惯了粗活,力","气比一般男子还要大,她一脚踹在刘","奎小腹上,“我能打你一次就能打你","第二次,除非你真不想要断子绝孙!","”\n  最后四个字她咬的格外用力",",刘奎已经被吓得魂不附体,只知道","连连点头。"]

自己尝试拆分后变成这样:

[["“哼!平时道貌岸然的在我面前装矜","持,现在还不是任我摆布?”\n  ","男人猥琐作呕的声音夹杂着湿热的气","息,在苏幼宁的耳边响起,紧接着一","双油腻腻的手就在她身上游离摸索起","来,令得她下意识的想要挣扎。\n "," 苏幼宁头疼欲裂,恍惚间看到有人","压在她的身上,立时抬腿一记猛顶,","痛的他当即惨叫连连。\n  她从床","上迅速翻起,抓过旁边炕上扔着的破","抹布就塞进了他的嘴里,霉臭味熏的","男人连连恶心。\n  看着面前年轻","了十几岁的刘奎,苏幼宁有些愣住了","。\n  她迟疑的看向自己的手,纤","细白嫩,并没有那么多的老茧和伤疤","。\n  老天爷这是开眼了吗?居然"],["让她重生了?\n  脑海中的记忆如","同潮水般的复苏袭来,苏幼宁眸带恨","意的盯向床上痛的生死未卜的地痞。","\n  就是这一天,她的后娘和继妹","为了能抢走她的婚约,故意给她下了","药物还把刘奎这个地痞引了进来,毁","了她的清白。\n  而继妹更是带了","一帮人来捉奸,把她和衣衫不整的刘","奎当场抓获,无奈下她只能嫁给刘奎",",从此过上了生不如死的日子。\n "," 村里头的人更是见到她就吐唾沫,","大骂她“不知羞耻”、“狐狸精”,","她原本的婚约也落到了继妹苏月安的","身上。\n  苏幼宁心里的恨意翻腾",",还好,还好老天爷有眼,让她回到","了祸端开始的这天。\n  “刚刚你"],["骂的很开心是吗?”苏幼宁冷冷的看","着痛的满头大汗的刘奎,二话不说抓","过桌上的茶盏,当头砸了下去!\n "," 想到前世在刘奎这所受的苦楚,苏","幼宁恨不能砸死他才能解恨。\n  ","刘奎惊恐绝望的痛嚎着,但却根本无","济于事。\n  苏幼宁一脚踩在他的","小腹上,揪起他杂乱的头发,眸子冷","的几乎要杀人,“说,是谁让你来毁","了我的?是高氏还是苏月安?”\n "," 面对着如同罗刹恶鬼般的苏幼宁,","刘奎慌的连忙点头。\n  他没想到","这瘦弱的苏幼宁居然这么大力气,打","得他毫无还手之力,身体下面更是痛","的几乎快要爆炸。\n  “她们都有","参与是吗?”\n  刘奎又止不住的"],["点头,生怕这姑奶奶又来一脚。\n "," 他费劲拽掉了口中的臭抹布,一把","鼻涕一把泪的哭道:“姑奶奶啊,我","知道错了!我以后肯定不敢打你的主","意了,求你放过我吧!”\n  “放","过你?那谁来放过我?”苏幼宁冷笑","不止,她上辈子就是被这个男人毁了","终生。\n  她捡起地上的碎碗片在","刘奎的脖子上比划着,声音冷的刺骨",",“记着,今天来这里的人是苏月安",",不是苏幼宁,被你睡了占便宜的是","她,她的胸上有块月牙的胎记,记住","了没?”\n  “记得!记得!”刘","奎吓得三魂都没了七魄,缠着嗓音哭","道:“今天来这里被占便宜的人是苏","月安,她的胸上有块月牙胎记!”\n"],["  “三天内把这件事散扬出去,听","见没?”苏幼宁因为干惯了粗活,力","气比一般男子还要大,她一脚踹在刘","奎小腹上,“我能打你一次就能打你","第二次,除非你真不想要断子绝孙!","”\n  最后四个字她咬的格外用力",",刘奎已经被吓得魂不附体,只知道","连连点头。"]]

请问如何将这段内容拆分为二维或者多维数组?

怎么去掉里面的[,\n 呢?


回答:

这应该是一个json字符串格式吧. 只要解析成json对象, \n就去掉了.

或者直接字符串替换就行. 看变量里面的是 '\n' 还是一个 换行.


回答:

你的内容已经是分行了的,数组中每个元素原来都是一行的,估计是因为显示视窗不匹配,需要再次组合后再分行吧。

这个需要根据一定的规则,组合(去除换行符),再计算字符来分行,再计算行数来分页。

以上是 请问如何将这段内容拆分为二维或者多维数组? 的全部内容, 来源链接: utcz.com/p/935749.html

回到顶部