sorteren mislukt
Het probleem is dat de array gevuld is vanuit 2 verschillende plaatsen. maar voor zover ik kan nagaan is de opbouw hetzelfde.
Het probleem is dat keys tot 1..398 correct gesorteerd worden (dus tot Ziggo) en de keys vanaf 398 .. 4xx ook (vanaf 'Bundel - Socket-1151 (h4)'). Alleen worden die 2 bereiken niet gemend. keys worden hernummerd, geen probleem.
Ik kan geen reden ontdekken waarom de sortering niet werkt. Op een bepaald moment werkt het sorteren wel, maar veranderingen later maakte dat ongedaan. En ik heb liever geen 'het werkt wel, maar waarom weet ik niet; oplossing.
dit is een deel van de input van de sort funktie
Code (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
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
<pre class="CodeBlock"><code>'array field='#397' --> array('Array')
'string' - key='#397' => field='name' --> string('Apple - MacBook Air')
'string' - key='#397' => field='image' --> string('ci-0397-apple-macbook-air.jpg')
'boolean' - key='#397' => field='generate' --> boolean('1')
'array' - key='#397' => field='entries' --> array('Array')
'integer' - key='#397' => field='id' --> integer('397')
'array field='#398' --> array('Array')
'string' - key='#398' => field='name' --> string('Desktop PC - SiYa Business PC upgrade')
'string' - key='#398' => field='image' --> string('pb-business-pc-upgrade.jpg')
'boolean' - key='#398' => field='generate' --> boolean('1')
'array' - key='#398' => field='entries' --> array('Array')
'string' - key='#398' => field='id' --> string('business-pc-upgrade')
'boolean' - key='#398' => field='is_combo' --> boolean('1')
'boolean' - key='#398' => field='is_pc' --> boolean('1')
'array field='#399' --> array('Array')
'string' - key='#399' => field='name' --> string('Desktop PC - SiYa Gamer PC compleet')
'string' - key='#399' => field='image' --> string('pb-gamer-pc-compleet.jpg')
'boolean' - key='#399' => field='generate' --> boolean('1')
'array' - key='#399' => field='entries' --> array('Array')
'string' - key='#399' => field='id' --> string('gamer-pc-compleet')
'boolean' - key='#399' => field='is_combo' --> boolean('1')
'boolean' - key='#399' => field='is_pc' --> boolean('1')
'array field='#400' --> array('Array')</code></pre>
dit is een deel van het resultaat van de sort funktie
<pre class="CodeBlock"><code>'array field='396' --> array('Array')
'string' - key='396' => field='name' --> string('Ziggo')
'string' - key='396' => field='image' --> string('ci-0189-ziggo.jpg')
'boolean' - key='396' => field='generate' --> boolean('1')
'array' - key='396' => field='entries' --> array('Array')
'integer' - key='396' => field='id' --> integer('189')
'array field='397' --> array('Array')
'string' - key='397' => field='name' --> string('Bundel - Socket-1151 (h4)')
'string' - key='397' => field='image' --> string('pb-socket-1151-h4.jpg')
'boolean' - key='397' => field='generate' --> boolean('1')
'array' - key='397' => field='entries' --> array('Array')
'string' - key='397' => field='id' --> string('socket-1151-h4')
'boolean' - key='397' => field='is_combo' --> boolean('1')
'boolean' - key='397' => field='is_pc' --> boolean('')
'array field='398' --> array('Array')
'string' - key='398' => field='name' --> string('Bundel - Socket-1151 (h4)+8g')
'string' - key='398' => field='image' --> string('pb-socket-1151-h4-plus-8g.jpg')
'boolean' - key='398' => field='generate' --> boolean('1')
'array' - key='398' => field='entries' --> array('Array')
'string' - key='398' => field='id' --> string('socket-1151-h4-plus-8g')
'boolean' - key='398' => field='is_combo' --> boolean('1')
'boolean' - key='398' => field='is_pc' --> boolean('')
'array field='399' --> array('Array')
'string' - key='399' => field='name' --> string('Bundel - Uw PC een 2e leven')
'string' - key='399' => field='image' --> string('pb-uw-pc-een-2e-leven.jpg')
'boolean' - key='399' => field='generate' --> boolean('1')
'array' - key='399' => field='entries' --> array('Array')
'string' - key='399' => field='id' --> string('uw-pc-een-2e-leven')
'boolean' - key='399' => field='is_combo' --> boolean('1')
'boolean' - key='399' => field='is_pc' --> boolean('')
'array field='400' --> array('Array')
'string' - key='400' => field='name' --> string('Desktop PC - SiYa Business PC upgrade')
'string' - key='400' => field='image' --> string('pb-business-pc-upgrade.jpg')
'boolean' - key='400' => field='generate' --> boolean('1')
'array' - key='400' => field='entries' --> array('Array')
'string' - key='400' => field='id' --> string('business-pc-upgrade')
'boolean' - key='400' => field='is_combo' --> boolean('1')
'boolean' - key='400' => field='is_pc' --> boolean('1')</code></pre>
'string' - key='#397' => field='name' --> string('Apple - MacBook Air')
'string' - key='#397' => field='image' --> string('ci-0397-apple-macbook-air.jpg')
'boolean' - key='#397' => field='generate' --> boolean('1')
'array' - key='#397' => field='entries' --> array('Array')
'integer' - key='#397' => field='id' --> integer('397')
'array field='#398' --> array('Array')
'string' - key='#398' => field='name' --> string('Desktop PC - SiYa Business PC upgrade')
'string' - key='#398' => field='image' --> string('pb-business-pc-upgrade.jpg')
'boolean' - key='#398' => field='generate' --> boolean('1')
'array' - key='#398' => field='entries' --> array('Array')
'string' - key='#398' => field='id' --> string('business-pc-upgrade')
'boolean' - key='#398' => field='is_combo' --> boolean('1')
'boolean' - key='#398' => field='is_pc' --> boolean('1')
'array field='#399' --> array('Array')
'string' - key='#399' => field='name' --> string('Desktop PC - SiYa Gamer PC compleet')
'string' - key='#399' => field='image' --> string('pb-gamer-pc-compleet.jpg')
'boolean' - key='#399' => field='generate' --> boolean('1')
'array' - key='#399' => field='entries' --> array('Array')
'string' - key='#399' => field='id' --> string('gamer-pc-compleet')
'boolean' - key='#399' => field='is_combo' --> boolean('1')
'boolean' - key='#399' => field='is_pc' --> boolean('1')
'array field='#400' --> array('Array')</code></pre>
dit is een deel van het resultaat van de sort funktie
<pre class="CodeBlock"><code>'array field='396' --> array('Array')
'string' - key='396' => field='name' --> string('Ziggo')
'string' - key='396' => field='image' --> string('ci-0189-ziggo.jpg')
'boolean' - key='396' => field='generate' --> boolean('1')
'array' - key='396' => field='entries' --> array('Array')
'integer' - key='396' => field='id' --> integer('189')
'array field='397' --> array('Array')
'string' - key='397' => field='name' --> string('Bundel - Socket-1151 (h4)')
'string' - key='397' => field='image' --> string('pb-socket-1151-h4.jpg')
'boolean' - key='397' => field='generate' --> boolean('1')
'array' - key='397' => field='entries' --> array('Array')
'string' - key='397' => field='id' --> string('socket-1151-h4')
'boolean' - key='397' => field='is_combo' --> boolean('1')
'boolean' - key='397' => field='is_pc' --> boolean('')
'array field='398' --> array('Array')
'string' - key='398' => field='name' --> string('Bundel - Socket-1151 (h4)+8g')
'string' - key='398' => field='image' --> string('pb-socket-1151-h4-plus-8g.jpg')
'boolean' - key='398' => field='generate' --> boolean('1')
'array' - key='398' => field='entries' --> array('Array')
'string' - key='398' => field='id' --> string('socket-1151-h4-plus-8g')
'boolean' - key='398' => field='is_combo' --> boolean('1')
'boolean' - key='398' => field='is_pc' --> boolean('')
'array field='399' --> array('Array')
'string' - key='399' => field='name' --> string('Bundel - Uw PC een 2e leven')
'string' - key='399' => field='image' --> string('pb-uw-pc-een-2e-leven.jpg')
'boolean' - key='399' => field='generate' --> boolean('1')
'array' - key='399' => field='entries' --> array('Array')
'string' - key='399' => field='id' --> string('uw-pc-een-2e-leven')
'boolean' - key='399' => field='is_combo' --> boolean('1')
'boolean' - key='399' => field='is_pc' --> boolean('')
'array field='400' --> array('Array')
'string' - key='400' => field='name' --> string('Desktop PC - SiYa Business PC upgrade')
'string' - key='400' => field='image' --> string('pb-business-pc-upgrade.jpg')
'boolean' - key='400' => field='generate' --> boolean('1')
'array' - key='400' => field='entries' --> array('Array')
'string' - key='400' => field='id' --> string('business-pc-upgrade')
'boolean' - key='400' => field='is_combo' --> boolean('1')
'boolean' - key='400' => field='is_pc' --> boolean('1')</code></pre>
Edit:
Ik heb code-tags geplaatst. Gelieve dit in het vervolg zelf toe te voegen aan je bericht.
Zie ook: Veel gestelde vragen: Welke UBB-codes kan ik gebruiken.
Zie ook: Veel gestelde vragen: Welke UBB-codes kan ik gebruiken.
Gewijzigd op 04/06/2018 22:53:43 door - Ariën -
Hm, dat is voor en na zie ik.
Misschien moet je je structuur eerst eens netjes neerzetten, kunnen we zien wat nou precies de bedoeling is.
Gewijzigd op 05/06/2018 08:07:43 door Rob Doemaarwat
Daar gaat de sort niet altijd goed mee om; je kunt beter de usort() functie gebruiken om zelf de array beter te sorteren. Bijv:
Het gaat dus om deze 2 velden, die er voor bv. key #397 niet aangemaakt zijn.
'boolean' - key='#399' => field='is_combo' --> boolean('1')
'boolean' - key='#399' => field='is_pc' --> boolean('1')
Overigens zou een speciale sort funktie beter zijn, want de sort is nu case sensitive. Gelukkig heeft dat geen invloed op het resultaat.
Gewijzigd op 07/06/2018 01:13:57 door kees buijs