/    Sign up×
Community /Pin to ProfileBookmark

split the fckeditor value

one of my form have a html editor with textarea named “description”

when user insert some data in textarea and click submit button i got that data in $_REQUEST[“description”] with different html tags like <p><b><u> etc

i store it in one variable $desc = $_REQUEST[“description”];

now i want to split that variable $desc in array, and each array have 100 words only,
for exaple the $desc has 450 words than new array has 5 elements and each have 100 words accept last; in last 50 words..

how can i archive this..

to post a comment
PHP

3 Comments(s)

Copy linkTweet thisAlerts:
@TeufelAug 18.2009 — Here you go:
[code=php]
$desc = $_REQUEST["description"];
$array = array();
while (sizeof($desc) > 0) {
$array[] = substr($desc, 0, 100);
$desc = substr($desc, 100);
}
print_r($array);
[/code]


It's untested, but it should work.
Copy linkTweet thisAlerts:
@GUIRAug 18.2009 — This may work, sorry had no time to check
<i>
</i>&lt;?php

$plaintext = strip_tags($desc);

$words_array = explode(' ',$desc);

$num_arrays = ceil(count($words_array)/100);
$arinc = 0;
$word_chunks = array();
for($i=1; $i &lt;= count($words_array);$i++)
{
if($i&amp;#37;100 == 0)
$arinc++;

<i> </i>$word_chunks[$arinc][] = $words_array[($i-1)];

}
$output = array();
foreach($word_chunks as $chunk)
{
$output[] = join(' ',$chunk);
}

?&gt;
Copy linkTweet thisAlerts:
@meralauthorAug 19.2009 — HI GUIR ...

thanks for reply...

but here still not working proper

because

  • 1. it removes all my html tags, i want the tags in output

  • 2. for example


  • <p>sadfdsfsdf&nbsp;&nbsp;&nbsp; fdfafdsdfs</p?<p?style="text-align:? center;">sadfsdasdsdf</p>

    your code cut the string from i put the ? and doesnt cut from where i put ?....

    [COLOR="DarkGreen"]



    [COLOR="Red"][U][I][B][B]in short i want all 100 words separate with its all tags ...

    [/B]
    [/B]
    [/I]
    [/U]
    [/COLOR]




    for example



    if i have output like..



    <p><b>this is bold</b></p> <p><i>this is italic</i></p> <p style="text-align: center;">this is center align</p>



    now i want all separate words like.....


    (1) <p><b>bold</b></p>

    (2) <p><i>italic</i></p>

    (3) <p style="text-align: center;">center-align</p>



    likewise upto hundered[/COLOR]
    ×

    Success!

    Help @meral spread the word by sharing this article on Twitter...

    Tweet This
    Sign in
    Forgot password?
    Sign in with TwitchSign in with GithubCreate Account
    about: ({
    version: 0.1.9 BETA 5.17,
    whats_new: community page,
    up_next: more Davinci•003 tasks,
    coming_soon: events calendar,
    social: @webDeveloperHQ
    });

    legal: ({
    terms: of use,
    privacy: policy
    });
    changelog: (
    version: 0.1.9,
    notes: added community page

    version: 0.1.8,
    notes: added Davinci•003

    version: 0.1.7,
    notes: upvote answers to bounties

    version: 0.1.6,
    notes: article editor refresh
    )...
    recent_tips: (
    tipper: @AriseFacilitySolutions09,
    tipped: article
    amount: 1000 SATS,

    tipper: @Yussuf4331,
    tipped: article
    amount: 1000 SATS,

    tipper: @darkwebsites540,
    tipped: article
    amount: 10 SATS,
    )...