I have a batch of code that builds a table using php variables.
What I am trying to do is capture the first 3 characters of flight.flightnum flight.flightnum returns BAW111 for example and I want the BAW bit. Easy right? Well I am now php expert but using substr is not working for me at all. Code as follows:
<script type="text/html" id="acars_map_row">
<tr class="<%=flight.trclass%>">
<td><a href="<?php echo url('/profile/view');?>/<%=flight.pilotid%>"><%=flight.pilotid%> - <%=flight.pilotname%></a></td>
<td><%=flight.flightnum%></td>
<td><%=flight.depicao%></td>
<td><%=flight.arricao%></td>
<td><%=flight.phasedetail%></td>
<td><%=flight.alt%></td>
<td><%=flight.gs%></td>
<td><%=flight.distremaining%> <?php echo Config::Get('UNITS');?> / <%=flight.timeremaining%></td>
</tr>
</script>
I have never worked with these types of variables before, I have tried:
<?php $result = "<%=flight.flightnum%>"; echo $result ?> // = BAW111
<?php $result = "<%=flight.flightnum%>"; echo substr($result, 0 ,3) ?> // gives an error and nothing is returned.
I'm sure its something obvious but im out of ideas.
gives an error... what error? What doesvar_dump($result);return?