I have an large array. I need to find the needle of a specific text.
Therefore I use:
$afmeting = array_search('extmax', $lines);
When I echo $afmeting
there is nothing there. But when I use print_r
on the array I see it is there (needle 41). So what might be wrong?
Array ( [0] => 0 [1] => section [2] => 2 [3] => header [4] => 9 [5] => acadver [6] => 1 [7] => ac1027 [8] => 9 [9] => acadmaintver [10] => 70 [11] => 105 [12] => 9 [13] => dwgcodepage [14] => 3 [15] => ansi_1252 [16] => 9 [17] => requiredversions [18] => 160 [19] => 0 [20] => 9 [21] => lastsavedby [22] => 1 [23] => user [24] => 9 [25] => insbase [26] => 10 [27] => 0 [28] => 20 [29] => 0 [30] => 30 [31] => 0 [32] => 9 [33] => extmin [34] => 10 [35] => 0 [36] => 20 [37] => 0 [38] => 30 [39] => 0 [40] => 9 [41] => extmax [42] => 10 [43] => 260 [44] => 20 [45] => 150 [46] => 30 [47] => 0 [48] => 9 [49] => limmin [50] => 10 [51] => -26 [52] => 20 [53] => -15 [54] => 9 [55] => limmax [56] => 10 [57] => 286 [58] => 20 [59] => 165 [60] => 9 [61] => orthomode [62] => 70 [63] => 0 [64] => 9 [65] => regenmode [66] => 70 [67] => 1 [68] => 9 [69] => fillmode [70] => 70 [71] => 1 [72] => 9 [73] => qtextmode [74] => 70 [75] => 0 [76] => 9 [77] => mirrtext [78] => 70 [79] => 1 [80] => 9 [81] => ltscale [82] => 40 [83] => 1 [84] => 9 [85] => attmode [86] => 70 [87] => 1 [88] => 9 [89] => textsize [90] => 40 [91] => 0.2 [92] => 9 [93] => tracewid [94] => 40 [95] => 05 [96] => 9)
print_r
gives: [41] => extmax
var_dump
gives: [41]=> string(8) "extmax "
EDIT after alle tips and tricks:
Thank you all for contributing, so when I use this code all should be ok?
$afmeting = array_search('string(8) "extmax "', $lines, true);
But still no value when I echo $afmeting
.