-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
68 lines (47 loc) · 1.32 KB
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<?php
$remark_text = 'Scuffing,Dent,School,abc,College,Brightsword,Sanu,Jeebendu,Anirudhha,Shruty Y';
echo $remark_text.'<br><br><br>' ;
$max_remark_length = 16;
$available_space = $max_remark_length;
$remarkArray = [];
$myremark = explode(",", $remark_text);
$i=0;$j=0;
foreach ($myremark as $remark){
$remarkArray[$j]='';
$remark_length =strlen($remark);
if($remark_length<$max_remark_length){
if($available_space>$remark_length){
if($j>0){
$remarkArray[$j].= ','.$remark;
}else {
$remarkArray[$j].= $remark;
$j++;
}
$available_space = $available_space-$remark_length;
}else {
$remarkArray[$j].= $remark;
$available_space=$max_remark_length;
$j++;
}
echo $remark_length.'=='.$remark.'--'.$available_space.'<br>';
}else{
if (count(explode(' ', $remark)) > 1) {
$remark_nospaces = explode(" ", $remark);
foreach($remark_nospaces as $remark_nospace){
$remarkArray[$j].= $remark_nospace;
$j++;
}
}else{
$remark_mores = str_split($remark,$max_remark_length);
foreach($remark_mores as $remark_more){
$remarkArray[$j].= $remark_more;
$j++;
}
}
}
$i++;
}
echo '-----------------------------------------------';
var_dump($remarkArray);
echo 'Remark is '.$i.'--Split into '.$j;
?>